C# List<T> class is used to store and fetch elements. It can also have duplicate elements. It is found in System.Collections.Generic namespace.
List<T> class in C# represents a strongly typed list of objects. List<T> provides functionality to create a list of objects, find list items, sort list, search list, and manipulate list items. In List<T>, T is the type of object.
What is the ‘T’ in List<T>?
List<T> class represents a strongly typed list of objects. List<T> provides functionality to create a list of objects, find list items, sort list, search list, and manipulate list items. In List<T>, T is the type of objects.
How to create List in C#?
List is a generic class and is defined in the System.Collections.Generic namespace. You must import this namespace in your project to access the List<T> class.
using System.Collections.Generic;
The List<T> is a generic collection, so you need to specify a type parameter for the type of data it can store. The following example shows how to create a list and add elements.