Simple generic collection to add elements
What collection should I use from C# that suports generic only for adding elements ?
I tried using ArrayList
, but I s开发者_开发百科ee that it's a non-generic type.
Sorry if this is a duplicate. Thanks.
Basic generic collection is List<T>
. It is in System.Collections.Generic namespace.
You can use it for example this way:
List<string> listOfStrings = new List<string>() { "This", "is", "list", "of", "strings" }
Here is all the generic collections in C#
System.Collections.Generic.List<T>
List<T>, IEnumerable<T>, ..
Are these the kind of things you're looking for? I don't really understand the question.
Hope this helps
You're probably after List. If you want a collection of unique elements, consider HashSet instead.
精彩评论