Get Max value after selecting in CSharp
Description
The following code shows how to get Max value after selecting.
Example
using System;/* w w w . ja v a2s . c om*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
static void Main(string[] args)
{
Random generator = new Random(0);
int[] numbers = new int[1000];
for (int i = 0; i < 1000; i++)
{
numbers[i] = generator.Next();
}
var queryResults = from n in numbers where n > 100 select n;
Console.WriteLine("Max of Numbers > 100");
Console.WriteLine(queryResults.Max());
}
}
The code above generates the following result.