This works fine with an array:
int[] a = new int[10]; for (int i = 0; i < 10; i++) { a[i] = i; }
But this raises an ArgumentOutOfRangeException with a list:
List<int> a = new List<int>(10); for (int i = 0; i < 10; i++) { a[i] = i; }
Why? I thought that lists use arrays inside.
source share