Javatpoint Logo
Javatpoint Logo

C# List<T>

C# List<T> class is used to store and fetch elements. It can have duplicate elements. It is found in System.Collections.Generic namespace.

C# List<T> example

Let's see an example of generic List<T> class that stores elements using Add() method and iterates the list using for-each loop.

Output:

Sonoo Jaiswal
Ankit
Peter
Irfan

C# List<T> example using collection initializer

Output:

Sonoo
Vimal
Ratan
Love
Next TopicC# HashSet




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA