Looking for c# Answers? Try Ask4KnowledgeBase
Looking for c# Keywords? Try Ask4Keywords

C# Language List


List<T> is a list of a given type. Items can be added, inserted, removed and addressed by index.

using System.Collections.Generic;

var list = new List<int>() { 1, 2, 3, 4, 5 };
Console.WriteLine(list.Count); // 6
Console.WriteLine(list.Count); // 5
Console.WriteLine(list[3]);    // 5

List<T> can be thought of as an array that you can resize. Enumerating over the collection in order is quick, as is access to individual elements via their index. To access elements based on some aspect of their value, or some other key, a Dictionary<T> will provide faster lookup.