LINQ: Linq stands for Language Integrated Query. It allows you to iternate, parse and function on different collections with the help of SQL type syntax.
Download LINQ Project: You can download the linq project from the linq website. After downloading the link project run the ReadMe.html file which will tell you how you can install it. I am not sure that if it installs on Visual Studio 2005 BETA I since I only tried on Visual Studio 2005 (Released Version). I have heard that some developers were able to install it on VS.NET 2005 BETA II.
Selecting all items from the string array:
string[] names = {"Azam","John Doe","Mary Kate","Alie"};
IEnumerable expr = names.Select( s => s );
foreach(string str in expr)
{
Console.WriteLine(str);
}
// OR You can also use this approach
IEnumerable expr = from s in names
select s;
foreach(string str in expr)
{
Console.WriteLine(str);
}
Using the Where Clause:
string[] names = {"Azam","John Doe","Mary Kate","Alie"};
// Only John Doe and Mary Kate will be selected
IEnumerable expr = from s in names
where s.Length > 6
select s;
foreach(string str in expr)
{
Console.WriteLine(str);
}
IEnumerable expr = from s in names
where s.Length > 6 && s[0] == 'J'
select s;
Count():
You can also get the number of items in your collection by simply using the count method.
string[] names = {"Azam","John Doe","Mary Kate","Alie"};
int count = names.Count();
Console.WriteLine(count); // print out 4
Combining Collections:
IEnumerable expr = from s in users, p in phones
where s.UserID == p.UserID
select p.PhoneNumber;
foreach(string str in expr)
{
Console.WriteLine(str);
}
These are just the basic operations that you can perform using LINQ. Download it and give it a try its awesome.