C# Tutorials - Herong's Tutorial Examples - v3.32, by Herong Yang
Creating and Using Arrays - Example
This section provides a tutorial example on how to create and use an array.
The following program is a good illustration of the different array syntaxes:
// Arrays.cs // Copyright (c) 2006 HerongYang.com. All Rights Reserved. class Arrays { static void Main() { int[] primes; primes = new int[10]; primes[0] = 2; primes[2] = 5; System.Console.WriteLine("The 3rd prime number is: {0}", primes[2]); double[] temperatures = new double[3]; temperatures[0] = 70.0; temperatures[1] = 75.0; temperatures[2] = 73.5; System.Console.WriteLine("Forecast for tomorrow's high" + " temperature: {0}", temperatures[2]); } }
Output:
The 3rd prime number is: 5 Forecast for tomorrow's high temperature: 73.5
Please note that:
Table of Contents
Logical Expressions and Conditional Statements
►Creating and Using Arrays - Example
Visual C# 2010 Express Edition
C# Compiler and Intermediate Language
Compiling C# Source Code Files
MSBuild - Microsoft Build Engine
System.Diagnostics.FileVersionInfo Class
WPF - Windows Presentation Foundation