Add:
using System.Linq;
to the top of your file.
And then:
Car[] carList = ...
var carMake =
from item in carList
where item.Model == "bmw"
select item.Make;
or if you prefer the fluent syntax:
var carMake = carList
.Where(item => item.Model == "bmw")
.Select(item => item.Make);
Things to pay attention to:
- The usage of
item.Makein theselectclause instead ifs.Makeas in your code. - You have a whitespace between
itemand.Modelin yourwhereclause