ASP.NET And LINQ Contd..
The belwo LINQ example will search and order a list of strings:
public partial class _Default : System.Web.UI.Page GridView1.DataSource = from city in cities GridView1.DataBind(); |
I’ve created an array of strings listing the cities I’ve visited from Jan->May of this year. I’m then using a LINQ query expression against the array. This query expression returns all cities where the city name is greater than 4 characters, and orders the result in alphabetical order and transforms those city names into upper case.
LINQ queries return results of type: IEnumerable<T> -- where <T> is determined by the object type of the “select” clause. In the above sample “city” is a string, so the type-safe result is a generics based collection like so:
Output:
Aspnet Discussion
- - Web application
- - Great Indian Developer Su
- - Aspx page inside Silverli
- - Open aspx page inside Sil
- - Guidance for a novice





