Foundations
Arrays
Arrays keep related values in order and let code read them by index.
Arrays
Arrays.cs
using System;
class Program
{
static void Main()
{
int[] scores = { 82, 91, 76 };
int bonus = ;
int firstScore = scores[0];
int adjustedScore = scores[1] + bonus;
Console.WriteLine($"first={firstScore}");
Console.WriteLine($"adjusted={adjustedScore}");
}
}
using System;
class Program
{
static void Main()
{
int[] scores = { 82, 91, 76 };
int bonus = ;
int firstScore = scores[0];
int adjustedScore = scores[1] + bonus;
Console.WriteLine($"first={firstScore}");
Console.WriteLine($"adjusted={adjustedScore}");
}
}
using System;
class Program
{
static void Main()
{
int[] scores = { 82, 91, 76 };
int bonus = ;
int firstScore = scores[0];
int adjustedScore = scores[1] + bonus;
Console.WriteLine($"first={firstScore}");
Console.WriteLine($"adjusted={adjustedScore}");
}
}
array index
Array indexes start at zero, so `scores[0]` reads the first value.