system.linq c# code example
Example 1: System Linq c#
int[] myNumbers = {5, 1, 8, 9};
Console.WriteLine(myNumbers.Max()); // 9
Console.WriteLine(myNumbers.Min()); // 1
Console.WriteLine(myNumbers.Sum()); // 23
Example 2: linq c#
// Data source
string[] names = {"Bill", "Steve", "James", "Mohan" };
// LINQ Query
var myLinqQuery = from name in names
where name.Contains('a')
select name;
// Query execution
foreach(var name in myLinqQuery)
Console.Write(name + " ");