Why does ImmutableList throw IndexOutOfRangeException instead of ArgumentOutOfRangeException when getting the element of the set at the given index? #108366
-
Why does ImmutableList throw IndexOutOfRangeException instead of ArgumentOutOfRangeException when getting the element of the set at the given index, but List throws an ArgumentOutOfRangeException exception? ImmutableList
List
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Tagging subscribers to this area: @dotnet/area-system-collections |
Beta Was this translation helpful? Give feedback.
-
It's probably for consistency with |
Beta Was this translation helpful? Give feedback.
-
I can't understand how using I spent more time looking at this and now think |
Beta Was this translation helpful? Give feedback.
-
It appears the documentation does not agree with the code. That is, the docs say using System.Collections.Immutable;
ImmutableList<int> list = ImmutableList.Create<int>([]);
Console.WriteLine(list[0]); It prints:
You can see the source for |
Beta Was this translation helpful? Give feedback.
This will be fixed by #108896 and dotnet/dotnet-api-docs#10573.