using System; class Program { static void Main(string[] args) { int[] numbers = new int[5]; numbers[0] = 1; numbers[1] = 3; numbers[2] = 5; numbers[3] = 7; numbers[4] = 9; int sum = 0; foreach (int number in numbers) { sum += number; } int max = int.MinValue; for (int i = 0; i < numbers.Length; i++) { if (numbers[i] > max) { max = numbers[i]; } } Console.WriteLine("Array: " + string.Join(", ", numbers)); Console.WriteLine("Sum: " + sum); Console.WriteLine("Max: " + max); } }This example creates an array of
int
values, initializes its values, and performs operations on it. The following steps are performed:
- Define an array of
int
values with five elements usingnew int[5]
.- Set the values of the array using the index operator (
[]
) and assignment statements.- Calculate the sum of the values using a
foreach
loop.- Find the maximum value of the array using a
for
loop and a comparison operation.- Output the array, sum, and maximum value to the console using
Console.WriteLine()
.Note that there are many other operations you can perform on arrays, such as sorting, searching, and filtering. This example is just one possible multi-step process for working with arrays.