vendredi 8 mai 2015

why in the collection interface the index is of type int? (signed) [duplicate]

This question already has an answer here:

Why the index type for the collection allow to accept negative index if they are not implemented?

silly ex:

List students = new List();
students[-1]; // will throw an OutOfRangeException

in other languages the -1 Index mean the last element. in C# is an out of range exception.

My question is:

Why in the collection interface is not used the Uint instead of int?

Any particular reason for this design policy?

Aucun commentaire:

Enregistrer un commentaire