List<T> (C#)
A List<T> is C#'s resizable array — an ordered collection of items of type T that can grow and shrink. You add items with .Add() and access them by zero-based index.
C#
List<T> lives in the System.Collections.Generic namespace. The T in angle brackets is the element type, so List<string> holds strings and List<int> holds integers.
It is the go-to collection in C# when you need an ordered list whose size changes. Use .Count for the number of items and .Remove() to take items out.
Syntax
List<T> name = new List<T>();Examples
C#
List<string> fruits = new List<string> { "apple", "banana" };
fruits.Add("cherry");
Console.WriteLine(fruits[0]);
Console.WriteLine(fruits.Count);Output:
apple
3