IEnumerablenumbers = new int[] { 1, 2, 3, 4 }; List numberList = numbers.ToList();
IEnumerableThis example is similar to the first one, but the variable contains an array of strings instead of integers. Package library: System.Collections.Generic is part of the .NET Framework Class Library, which is included in the Microsoft .NET Framework.colors = new string[] { "red", "blue", "green" }; List colorList = colors.ToList();