c# linq select where in list code example
Example 1: c# linq select from object list
var correct = answers.First(a => a.Correct);
var correct = answers.FirstOrDefault(a => a.Correct);
var allCorrect = answers.Where(a => a.Correct).ToList();
Example 2: linq where in list
var allowedStatus = new[]{ "A", "B", "C" };
var filteredOrders = orders.Order.Where(o => allowedStatus.Contains(o.StatusCode));
Example 3: linq query select where c#
var queryLondonCustomers = from cust in customers
where cust.City == "London"
select cust;