int[] arr = {1, 2, 3}; var list = new List<int>(arr); list.Add(4); Console.WriteLine(arr.Length); Console.WriteLine(list.Count);
The array arr has a fixed length of 3. The List list is created from the array and then an element is added, so its count becomes 4. The array length remains 3.
Arrays have a fixed size once created. Collections like List
int[] arr = {10, 20, 30}; List<int> list = new List<int>(arr); arr[0] = 100; list[1] = 200; Console.WriteLine(arr[0]); Console.WriteLine(list[1]);
The List is created as a copy of the array elements. Changing the array element at index 0 changes arr[0]. Changing the list element at index 1 changes list[1]. They are independent after creation.
int[] arr = new int[3]; arr[3] = 10;
The array has length 3, so valid indices are 0, 1, and 2. Accessing index 3 is out of range and causes an IndexOutOfRangeException.
List<string> is designed to grow and shrink dynamically, making it the best choice for a changing list of user names. Arrays have fixed size and require manual resizing.