linq query c# code example
Example 1: linq query select where c#
var queryLondonCustomers = from cust in customers
where cust.City == "London"
select cust;
Example 2: linq in c#
string[] names = {"Bill", "Steve", "James", "Mohan" };
var myLinqQuery = from name in names
where name.Contains('a')
select name;
foreach(var name in myLinqQuery)
Console.Write(name + " ");
Example 3: linq in c#
class LINQQueryExpressions
{
static void Main()
{
int[] scores = new int[] { 97, 92, 81, 60 };
IEnumerable<int> scoreQuery =
from score in scores
where score > 80
select score;
foreach (int i in scoreQuery)
{
Console.Write(i + " ");
}
}
}