The following code:
private void button1_Click(object sender, EventArgs e)
{
1 // create the array
2
3 int[] ml = new int[7] { 5, 3, 7, 9, 2, 6, 8 };
4
5 // loop through the contents of the ml array
6
7 string x = "";
8
9 for (int i = 0; i < ml.Length; i++)
10 {
11 x += Convert.ToInt32(ml[i]) + " ";
12 }
13
14 MessageBox.Show(x, "Contents of Array"); }
Well the 3rd line defines the array, what type of an array and the number of data pieces. We also define which characters.
In the 7th line we create a variable "x" to show the contents of the array later on.
In the 9th line we say that for each time that the variable "i" (which we set equals to 0 at first) is smaller than the number of pieces in the "ml" array (7 pieces) - add 1 to the "i" variable.
In the 11th line - I dont understand what we are doing really...Can anyone have a look and explain to me as bright as he can what's going on?
And if my assumptions on the early lines are wrong - please tell me so I would know i'm making a mistake.
Before I finish this message I wanna point out -
If my assumptions were right about the array statements, it means that once the variable "i" will equal 7 - something will happen. It keeps showing the messagebox, does that still mean that "i" is now equal or larger than 7?
Isn't the loop supposed to stop because of that?
Appreciate the effort for the one who will clarify this for me :)


Sign In
Create Account


Back to top









