Hi,
I have written a piece of code to attempt storing the first 3 even numbers into an array called EvenNumbers.
Here is my code
How do I say in C# "continuing doing while the last index in the array is empty i.e. EvenNumbers[2] is empty or is null?
I have written a piece of code to attempt storing the first 3 even numbers into an array called EvenNumbers.
Here is my code
C#:
using System;
namespace Sample
{
class Program
{
static void Main()
{
int[] EvenNumbers = new int[3];
Console.WriteLine(EvenNumbers.GetLength(0));
int counter = 1;
int i = 0;
do
{
if (counter % 2 == 0)
{
EvenNumbers[i] = counter;
i++;
}
counter++;
} while (EvenNumbers[2] == null); //need help here, I want to say keep doing this loop whilst the last array index is empty
}
}
}
How do I say in C# "continuing doing while the last index in the array is empty i.e. EvenNumbers[2] is empty or is null?