Content
We can access the length of an array using .Length:
int[] numbers = { 2, 3, 1 };
Console.WriteLine("Length: " + numbers.Length);
// Output: Length: 3
Practice
Given the nums array:
int[] nums = { 2, 3, 1 };
Find out what its first value is and check its length:
Console.WriteLine("Length: " + nums.???);
// Output: Length: 3
Console.WriteLine("First Element: " + nums???);
// Output: First Element: 2
Length
[0]
[1]
size
Revision
Given the nums array:
int[] nums = { 2, 3, 1 };
Find out what its first value is and check its length:
Console.WriteLine("Length: " + nums.???);
// Output: Length: 3
Console.WriteLine("First Element: " + nums???);
// Output: First Element: 2
Length
[0]
[1]
size