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
2010-01-16 10:11:49
+2
A:
System.Collections.Generic.LinkedList<T> achieves the same funcionality.
Yossarian
2010-01-16 10:14:56
+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
2010-01-16 10:16:43
+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
2010-01-16 10:20:59
Thanks a lot :)
Mishgun_
2010-01-16 10:22:27
You are welcome
Petros
2010-01-16 10:25:57