Magic Chewing Gum
OK I'm going to tell you something really cool. If nothing else this should be the reason to switch to c#... LINQ or Language Integrated query.
Technically LINQ is magic chewing gum created by Celtic druids 5,000 years ago out of the residue at the bottom of guiness barrels to bring all the warring tribes of Ireland together. Fionn McCool tried it and became king. At the annual spitting contest he spat a wad so far that it exploded through a worm hole ending up on Anders Hejlsberg's desk in Redmond as a USB stick of Juicy fruit. Once Anders plugged the magic chewing gum into his PC he was able to incorporate LINQ into .Net and this virtual gum is now able to stick together disparate pieces of data from any source whatsoever.
With LINQ C# is now a juicy data oriented language.
The problem we face today is a multitude of different types of data such as Microsoft excel spreadsheets, the e-mail messages, xml, databases, queues, registries, blah blah blah. With each of these comes their own awful object model. You have to learn all these terrible APIs and access methodologies like a dope which is another big turnoff with these multiplatform development systems like .net. With LINQ there is now a single way to access any type of data. You can query iSeries data, arrays, xml all in the same way without sacrificing what you can do with all these types of data. Another plus is that when you compile your code with LINQ statements they are checked for the correct type of field and objects. You know this in RPG when you try to compile a program without defining the field that you are using.
I know you're probably thinking that ODBC does the same thing because you can use SQL statements to access different types of databases but it doesn't check the types at compile time and it only works for relational databases. LINQ has turned c# into a real language. It makes it more of a data language. It makes it cool.
Here's a simple example:
Linq Where selection
You can only have a beer if you're over 21. The query expression creates a new sequence of numbers that satisfy the selection criteria. The for each section iterates over each element in this new sequence and prints its value.
public void AllowedToDrink() {
int[] numbers = { 25, 1, 17, 44, 20, 9, 81, 26, 37, 12, 0 };
var lowNums =
from n in numbers
where n > 20
select n;
Console.WriteLine("These People Can Have a Beer:");
foreach (var b in lowNums) {
Console.WriteLine(b);
}
}
Result
Numbers > 21 :
4
1
3
2
0