Things You'll Need:
- C# integrated development environment
- C# compiler
-
Step 1
Install Visual Studio (see Resources below). From the main window's "File," select "New," then select "Project." In the "New Project" Dialog Box that appears, expand the "C# Project Type" and highlight "Windows."
-
Step 2
Highlight "Console Application" under "Visual Studio Installed Templates" in the "Templates" pane. Click "OK" to create the project.
-
Step 3
Locate the "Main" method in the "Program.cs" file. Note the curly braces which are below it. Your code must be written between these opening and closing braces. It's alright to make some new, empty lines in there by positioning the cursor after the first brace and then pressing "Enter" a number of times.
-
Step 1
Start to create an array in C# by typing the data type of your array, followed by an opening square bracket, then a closing square bracket, in the newly created space. An example, using the "int" data type, looks like this:
int[] -
Step 2
Type a blank space on the same line, and then type the name you will use for your new array. For example:
int[] myIntArray -
Step 3
Continue on the same line by typing a blank space, an "equals" sign and another blank space. Type the "new" keyword followed again by the data type and an opening and closing square bracket. So far, your line should look like this:
int[] myIntArray = new int[] -
Step 4
Initialize your array with some data. Use a comma-separated list enclosed in curly braces followed by a semicolon. Here is an example using the integers 1 to 5:
{1, 2, 3, 4, 5} -
Step 5
Verify that your C# array declaration is complete. It should look like this:
int[] myIntArray = new int[] { 1, 2, 3, 4, 5 };









