views:

71

answers:

4

I used to use List.h to work with lists in C++, but are there any similar libraries in .Net ? Becouse I can't use List.h for managed types.

+7  A: 

Check out the System.Collections and System.Collections.Generic namespaces. There, you'll find classes like ArrayList, List<T>, etc...

Frederik Gheysels
+2  A: 

System.Collections.Generic.LinkedList<T> achieves the same funcionality.

Yossarian
+1  A: 

If you're referring to the STL list then you'll want the the LinkedList generic class found in System.Collections.Generics

The .Net List generic class is more like an STL vector

Sean
+3  A: 

Here is an example of using List:

List<string> myList = new List<string>();
myList.Add("Item1");
myList.Add("Item2");
myList.ForEach(s => Console.WriteLine(s.ToString()));

and here is an example of LinkedList:

LinkedList<int> myList = new LinkedList<int>();

myList.AddFirst(14);             
myList.AddLast(20);                            
myList.AddLast(34);             
myList.AddBefore(myList.Last, 65); 

LinkedListNode<int> myNode = myList.First;
while (myNode != null)
{
  Console.WriteLine(myNode.Value);
  myNode = myNode.Next;
}
Petros
Thanks a lot :)
Mishgun_
You are welcome
Petros