shopify traffic stats

How to Create C# Arrays

a C# Array with initial values:

//In the example below I created an array called Names.  I put 3 values into it (the 3 names).  I then created a messagebox that display the value of 1 in the array.  In this case Bob is position 1 (like any other programming language we start counting from 0 – like 0,1,2)

string[ ] Names = { “Matt”, “Bob”, “Kay” };

The result is:
c# array 

Creating an empty C# Array

string[] Lastnames = new string[3];  //create an empty array that can hold 3 values.
Lastnames[0] = “Rizos”;  //call the Lastnames array and “put” the string value Rizos in the 0 position
MessageBox.Show(Lastnames[0]);  //have a messagebox that calls the Lastnames array, position 0.  The result is:

Screen Shot 2013-07-17 at 9.40.49 AM

Share This
%d bloggers like this: