CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006
    Posts
    170

    [RESOLVED] List in a List? List<List<string>>

    I want to make a List containing a List that contains strings. I don't know how to do that. Can I get a code example please?

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: List in a List? List<List<string>>

    You already have the answer in your title. ;-)

    A little example

    Code:
             List<List<string>> doubleStringList = new List<List<string>>();
    
             List<string> tempList = new List<string>();
             tempList.Add("list1");
             doubleStringList.Add(tempList);
    
             List<string> tempList2 = new List<string>();
             tempList2.Add("list2");
             tempList2.Add("list2secondItem");
             doubleStringList.Add(tempList2);
    Debug and see what's in the doubleStringList

  3. #3
    Join Date
    May 2006
    Posts
    170

    Talking Re: List in a List? List<List<string>>

    haha I was to quick to ask has just missed the () !! Thank you!!

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