Sorry i want to store specific input data/numbers in an array. In my array i want only the correct numbers to be stored and not the wrong once. I want the proram to continue as long as i have not gotten 4 correct number in my array. Then i want to print out the total number of array value. How can I do this in C#? Here is my code:
int min = 5;
int max = 10;
int[] array = new int[4];
int count = 0;
for (int i = 0; i < array.Length; i++)
{
Console.WriteLine("enter btw 5 och 10");
int val = int.Parse(Console.ReadLine());
array[i] = val;
if (val >= min && val <= max)
{
Console.WriteLine("Correct, continue...");
count++;
continue;
}
else
{
Console.WriteLine("wrong, enter btw 5 och 10");
continue;
}
}
Console.WriteLine(count);
Console.ReadKey();
}
If someone enter e.g 11 or 2, the program will not count it. Thank you for the help.