Numeric Aggregates: max : Max « LINQ « C# / CSharp Tutorial






using System;
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());

        }
    }








22.54.Max
22.54.1.Max on int array
22.54.2.Max on String array
22.54.3.Max on object list
22.54.4.Max on Object list array
22.54.5.Using Max to get the highest number in an integer array.
22.54.6.uses Max to get the length of the longest word in a string array.
22.54.7.Grouped Max
22.54.8.Get the Min and max value from a query
22.54.9.Numeric Aggregates: max