What is Linq? Basic Introduction.

1:56 AM
Linq = "Language Integrated Query"

LINQ defines a set of method names (called standard query operators, or standard sequence operators), along with translation rules from so-called query expressions to expressions using these method names, lambda expressions and anonymous types.

LINQ is a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities.

LINQ was released as a part of .NET Framework 3.5 on November 19, 2007.

LINQ Providers:

1. LINQ to Objects
2. LINQ to XML
3. LINQ to SQL
4. LINQ to DataSets
5. Other Providers


string[] strData = { "William H. Gates III", "Warren Edward Buffet", "Paul Gardner Allen", "Sultan Hassanal Bolkiah", "King Fahd Bin Abdulaziz Alsaud", "Sheikh Zayed Bin Sultan Al Nahyan", "Steven Anthony Ballmer", "Amir Jaber Al-Ahmed Al-Jaber Al sabah", "Phillip F. Anschutz", "Michael Dell" };
            var ans =
                from s in strData
                where s.Contains("Gates")
                select s;

            string strFound = "";
            foreach (var t in ans)
                strFound += t.ToString() + Environment.NewLine ;

As you can see we have a string array containing the Names. i want to a particular name containing string "Gates".

At the End strFound string will contain "William H. Gates III" as it is the only name containing the string "Gates"


Post a Comment