Monday, 9 July 2018

018 LINQ Max


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.
---------------------------------------

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
---------------------------------------------

No comments:

Post a Comment

বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...