0% found this document useful (0 votes)
26 views

Task 1 - Creating The Foreachsyntax' Project: File - New - Project Menu Command

The document describes creating a C# console application project named "ForeachSyntax" using Visual Studio. It then shows code using a foreach loop to iterate through an integer array and print each element, building and running the application to test it works as expected.

Uploaded by

Tram Nguyen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Task 1 - Creating The Foreachsyntax' Project: File - New - Project Menu Command

The document describes creating a C# console application project named "ForeachSyntax" using Visual Studio. It then shows code using a foreach loop to iterate through an integer array and print each element, building and running the application to test it works as expected.

Uploaded by

Tram Nguyen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Task 1 – Creating the ‘ForeachSyntax’ Project

1. Click the Start | Programs | Microsoft Visual Studio | Microsoft Visual Studio menu
command.
2. Click the File | New | Project… menu command.
3. In the New Project dialog select the Visual C# | Windows project type.
4. Select the Console Application template.
5. Provide a name for the new project by entering “ForeachSyntax” in the Name field.

6. Click OK.
Task 2 – Declaring Simple Array and using foreach struct
1. In the Solution Explorer, double click on Program.cs to open the source code.
2. Add array A and some code to used foreach struct in Main of Program class:
static void Main(string[] args)
{
int[] A = { 2, 3, 4, 5, 6, 7, 8, 9 };
foreach (var x in A)
{
Console.WriteLine(x);
}
Console.WriteLine(“Press any key to continue…”);
Console.Readkey();
}

3. Press Ctrl+F5 to build and run the application, displaying the output in a console
window:

4. Press any key to close the console window and terminate the program.

You might also like