CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18

Thread: ArrayList

  1. #16
    Join Date
    Jun 1999
    Posts
    153

    Re: ArrayList

    Quote Originally Posted by lsy
    i'm looking for something like an array or structure with 1 index hold multiple value! so the index will be my reference point for that particular record or values...
    Sounds like you need a multi-dictionary. The free PowerCollections library on codeplex provides such a data structure.

    PowerCollections

    MultiDictionary

    Here's a usage example:

    MultiDictionary Example
    Last edited by Kevin McFarlane; December 21st, 2007 at 08:47 AM.
    Kevin

  2. #17
    Join Date
    Dec 2006
    Posts
    203

    Re: ArrayList

    Quote Originally Posted by lsy
    i'm looking for something like an array or structure with 1 index hold multiple value! so the index will be my reference point for that particular record or values...
    So, a multidimensional array? ;o
    Sincerely,

    Martin Svendsen

  3. #18
    Join Date
    Oct 2005
    Location
    Islamabad, Pakistan
    Posts
    1,277

    Re: ArrayList

    Sample using hashtable
    Code:
    private void Form1_Load_1(object sender, System.EventArgs e)
    {
        Hashtable h = new Hashtable();
        
        h.Add(1, new Student("anis", "khan"));
        h.Add(10, new Student("sami", "khan"));
        
        Text = ((Student)h[10]).FirstName;
    }
    Code:
    private struct Student
    {
        private string m_FirstName;
        private string m_LastName;
        
        public Student(string firstName, string lastName)
        {
            m_FirstName = firstName;
            m_LastName = lastName;
        }
        
        public object FirstName {
            get { return m_FirstName; }
        }
        
        public object LastName {
            get { return m_LastName; }
        }
    }
    Last edited by aniskhan; December 21st, 2007 at 12:58 PM.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured