0

When declaring myArray[5] it's creates elements from [0] to [4] why not from [0] to [5]?

and I get ... that is one more element :) but that's not the case

5th May 2016, 3:33 PM
Piotr Stryjecki
8 Antworten
+ 2
with the declaration myArray [5] you say, you want 5 placeholders in your Array. Because Arrays are zero-indexed the first placeholder has the index 0. So it's start with 0 and thats xour first index. Because you declared it with an index of 5 you get 4 more. So 1 is the second index, 2 the third, 3 the fourth and 4 is the last index you get
14th Jun 2016, 11:37 AM
Nicolas Klein
Nicolas Klein - avatar
+ 1
Because it starts from 0, not from 1 (i.e. 0,1,2,3,4 it is five elements)
14th May 2016, 10:18 AM
Almaro
+ 1
because you declare one array whit 5 elements 1) myArray[0] 2) myArray[1] 3) myArray[2] 4) myArray[3] 5) myArray[4]
15th Jun 2016, 5:27 PM
Tommaso
+ 1
Simple Answer: C# uses ZERO-Based Indexing i.e., Arrays, Collections, etc First Element Is at 0th Location. Thanks
16th Jun 2016, 5:08 PM
Aamir Bashir
Aamir Bashir - avatar
0
when you instantiate an array, you declare it's size. but when you give them value, their index start from 0.
20th May 2016, 6:13 AM
Burakcan Duzcan
Burakcan Duzcan - avatar
0
C# it's a zero-indexed programing lenguage. that means 0 it's the 1st value.
11th Jun 2016, 1:22 AM
Pablo Hernandez
0
In declaring an array, you list the number of elements. In calling it, you call an element from its index position, and indexes start from 0 as c# is a zero-indexed language.
15th Jun 2016, 12:01 AM
lemonbalm
0
So that means C# uses 0-based indexing but not 0-based declarations?
29th Jun 2017, 2:39 PM
Ken