I have an int array that store age values. I want to print all the values in the array which are above or eqaul to 18.
int[] age = new int[] { 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 };
foreach(int item in age)
{
}
I tried something like this but didn't work.
int[] age = new int[] { 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 };
int targetAge = 18;
int findedAge = Array.FindIndex(age, age => age == targetAge);
if (age>= targetAge)
{
foreach (int item in age)
{
Console.WriteLine(item);
}
}