Friday, September 17, 2004 12:11 AM
pgolde
Silly inconsistencies
When you index an array with an index that is out of bounds, you get an IndexOutOfRangeException:
int[] array = new int[5];
array[7] = 1; // throws IndexOutOfRangeException
When you index a List with an index that is out of bounds, you get an ArgumentOutOfRangeException:
List<int> list = new List<int>();
list[-1] = 1; // throws ArgumentOutOfRangeException
Was this intentional or just a silly oversight? Is there any benefit of having these two exceptions be different?