0

Why does C# use int for indicing of elements for example result = arr[(int)index];? This is for me illogical because indices can't be negative.

The same is also true for example for int rand = random.Next((int)max), why is the parameter an int even if it can't be negative?

Quonux
  • 2,975
  • 1
  • 24
  • 32
  • actually, in a multi-dimensional array (don't use them) indicies can be negative. – Jodrell Feb 14 '14 at 17:27
  • Why *not*? What's wrong with an `int` convention? – Haney Feb 14 '14 at 17:27
  • This question is probably better suited for [Programmers](http://programmers.stackexchange.com/) than StackOverflow. – Ally Feb 14 '14 at 17:27
  • As p.s.w.g. commented, the answer is in that post. But some indexes can be negative as stated in that answer. `ComboBox.SelectedIndex` can be -1, and I would be willing to bet others as well. – Evan L Feb 14 '14 at 17:31

0 Answers0