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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA