LINQ
language integrated query—introduces many extensions methods to the standard C# environment. These methods work on Lists, arrays and collections that are not yet in memory. Some of these are helpful. Some are less helpful.
this example we use the Average extension method
using System;
using System.Linq;
class Program
{
static void Main()
{
int[] array = { 1, 3, 5, 7 };
Console.WriteLine(array.Average());
}
}
output 4
LINQ makes the concept of querying a first-class programming concept in .NET. The data to be queried can take the form of XML (LINQ to XML), databases (LINQ-enabled ADO.NET: LINQ to SQL, LINQ to Dataset and LINQ to Entities) and objects (LINQ to Objects). LINQ is also highly extensible and allows you to build custom LINQ enabled data providers
var result = from c in Customers where c.City == Udgir" orderby c.LastName descending select new { c.FirstName, c.LastName, c.Address };
using System.Linq;
class Program
{
static void Main()
{
int[] array = { 1, 3, 5, 7 };
Console.WriteLine(array.Average());
}
}
output 4
LINQ makes the concept of querying a first-class programming concept in .NET. The data to be queried can take the form of XML (LINQ to XML), databases (LINQ-enabled ADO.NET: LINQ to SQL, LINQ to Dataset and LINQ to Entities) and objects (LINQ to Objects). LINQ is also highly extensible and allows you to build custom LINQ enabled data providers
var result = from c in Customers where c.City == Udgir" orderby c.LastName descending select new { c.FirstName, c.LastName, c.Address };
No comments:
Post a Comment