The Max operator returns the highest numeric element from a collection.
Below example is query of LINQ Max method.
----------------------------------------------
using System;
using
System.Collections.Generic;
using
System.Data.SqlClient;
using
System.Data.Sql;
using
System.Data;
using
System.Linq;
using
System.Collections;
using
System.Xml;
using
System.Xml.Linq;
using
System.IO;
namespace
ConsoleApplication1
{
class
Program
{
static
void
Main(string[]
args)
{
int[]
marks = { 10, 20, 30, 40, 50, 60 };
int
sumOfMarks = (from
x in
marks select
x).Max();
Console.WriteLine("The
Maximum is :"
+ sumOfMarks.ToString());
Console.ReadKey();
}
}
}
//The
Maximum is :60
----------------------------------------
Below example is query of Lambda expression Max method.
---------------------------------------
----------------------------------------
Below example is query of Lambda expression Max method.
---------------------------------------
using
System;
using
System.Collections.Generic;
using
System.Data.SqlClient;
using
System.Data.Sql;
using
System.Data;
using
System.Linq;
using
System.Collections;
using
System.Xml;
using
System.Xml.Linq;
using
System.IO;
namespace
ConsoleApplication1
{
class
Program
{
static
void
Main(string[]
args)
{
int[]
marks = { 10, 20, 30, 40, 50, 60 };
int
sumOfMarks = marks.Max(a=>a);
Console.WriteLine("The
Maximum is :"
+ sumOfMarks.ToString());
Console.ReadKey();
}
}
}
//The
Maximum is :60
---------------------------------------------