Order by select in Lambda Expressions in Linq.

Posted by Vishalneeraj-24503 under LINQ category on | Points: 40 | Views : 1169
See the below C# code for select and Order by lambda expression operators.
Must import System.Linq Namespace.using IEnumerable class,we can do
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

protected void Page_Load(object sender, EventArgs e)
string[] country = { "india", "Morocco", "Canada",
"Switzerland", "Kenya", "Brazil",
"Cyprus", "Senegal","Finland","Algeria","Maldives" };
IEnumerable<string> GetCountry = from listOfcountries in country
orderby listOfcountries
select listOfcountries;

foreach (string strCountry in GetCountry)
Response.Write(strCountry + "<br/>");

Comments or Responses

Login to post response