Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 see that it's a non-generic type.

Sorry if this is a duplicate. Thanks.

like image 667
Adrian Avatar asked Apr 11 '26 03:04

Adrian


1 Answers

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#