It supports compile time checking for syntax errors and type safety.
LINQ provides complete query language for any collection that implements IEnumerable
Let’s see LINQ in action. Currently the most recommended way of trying LINQ id Beta 1 of Orcas which has LINQ framework integrated with it.
Consider the program below :
using System;
using System.Collections.Generic;
using System.Linq; using System.Text;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
string[] words = new string[5]
{ "Word1", "World", "Word2", "Word3", "Word4" };
IEnumerable
{
Console.WriteLine("Hello " + name);
}
}
}
}
Output :
Hello World
In above program we query the list of words for a particular word ‘World’ and then prints ‘Hello World’ the number of times the word is found. Instead of using ‘if’ keyword, LINQ adds the capability of querying the local variables using very familiar SQL type querying capabilities.
With LINQ comes lot of new concepts which I will cover in detail very soon, but here is the list :
1. Immediate & Deferred execution of queries.
2. Forced Immediate Execution
3. Standard Query Operator Extension Methods