Skip to main content

Lambda Query

What is a Lambda Expression?

            A lambda expression is an anonymous function. It allows to write a method in the same place you are going to use it.
 syntax : Parameters => Executed code.

Basic Lambda Expression

1)Where

  List<int> mark = new List<int>{90, 71, 82, 93, 75, 82 };
  var result= mark.Where(n => n > 80);
  Console.WriteLine("Values greater than 80 are");  
  foreach(val item in result)
     { 
      Console.WriteLine("{0}", item ); 
     }
// Outputs: 
// Value greater than 80 are
// 90
// 82 
// 93
// 82

2)Count()

  int result= mark.Where(n => n > 80).Count() ;
  Console.WriteLine("{0} markare greater than 80", result);
 // Outputs: 
 // 4 mark are greater than 80
 

3)Sum()

 int result= mark.Where(n => n > 80).Count() ;
 Console.WriteLine("{0} markare greater than 80", result);   
// Outputs: 
// Sum of mark greater than 80 are
// 347 

Comments

Popular posts from this blog

NuGet - Check Combo Box

Step 1:  Get the NuGet package https://www.nuget.org/packages/Common.CheckComboBox/ Step 2: Add the CheckComboBox Control in the toolbar. Click here Step 3: Drag the "CheckedComboBox" control from the toolbar to the form to the position where it should be placed   Step 4: Add items to the CheckedComboBox control by        for (int i = 0; i < 10; i++)             {                 checkedComboBox1.Items.Add(i);             }

NuGet - Common Security

Step 1: Get the NuGet package  https://www.nuget.org/packages/Common.Security/ Set the property with a string Security.CypherPassWord Security.CypherPassWord = "CypherPassWord"; Call the static method for  Security.Encrypt()  syntax :       Security.Encrypt(planeText,password) Call the static method for  Security.Decrypt()  syntax :       Security.Decrypt(planeText,password)
HOW TO RESOLVE REPORTING SERVICES CATALOG DATABASE FILE EXISTENCE FAILED OR TEMPORARY DATABASE FILE EXISTENCE FAILED Next to go to the Sql server root directory, by default C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA Files to be deleted ReportServer.mdf ReportServer_log.LDF ReportServerTempDB.mdf ReportServerTempDB_log.LDF .