August 2017
Beginner
566 pages
12h 34m
English
A big thing with arrays is the concept of an index. So how does that matter? Take a look. Remember, the array we just created is designed to store two entries, because there's a 2 where it says new decimal. However, the entries are not stored at index 1 and index 2; the word index is simply a fancy word for address. That's it.
Let's actually add this as comment 6 on the next line:
//6. index in this context is just the same as saying address: 0,1 and NOT 1,2
In our particular case, because the length of the array is 2, the addresses or the indexes go from 0 to 1 as 0,1 and not 1,2. So, even though we might naturally be inclined to count 1, 2, 3, and so forth, in C# you begin at 0, not at 1:
values[0] = decimal.Parse(TextBox1.Text); ...
Read now
Unlock full access