Im just starting to learn how to use LinQ, I want to only show grades that are 9 and 10 from a list i have but when trying to use var and foreach it wont let me, not sure why.
This is the list i was provided:
int[] grades= { 5, 9, 7, 8, 6, 9, 5, 7, 7, 4, 6, 10, 8 };
And here im trying to do the query:
var grades1 = from s in grades
where s.grades>= 9
select s;
foreach (var cal in grades)
Console.WriteLine(cal.grades);
The thing is that it shows an error when doing s.grades and cal.grades. I cant change the int[]grades.
grades1and then usinggradessrepresents an element ofgrades. Sincegradesis anint[],sis anint. So it needs to bewhere s >= 9.