Home > LINQ > LINQ – Makes programming easier

LINQ – Makes programming easier

I am in favor of the idea that every new technology should be only used if they can solve a problem or makes or at least its benefit can justify the required effort for learning curve.

LINQ is one of those technologies that when I learn about that I could not find a really benefit, but when I tried that I stunt how effective it can be in reducing programming efforts.

This is a very basic and simple example from Microsoft website:

public void Linq13() {
    int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
    string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

    var lowNums =
        from n in numbers
        where n < 5
        select digits[n];

    Console.WriteLine("Numbers < 5:");
    foreach (var num in lowNums) {
        Console.WriteLine(num);
    }    
}

Result

Numbers < 5:
four
one
three
two
zero

To for examples on LINQ:

C# 101 Examples: http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx

VB 101 Examples: http://msdn.microsoft.com/en-us/vbasic/bb688088.aspx

VB Query Examples: http://msdn.microsoft.com/en-us/vbasic/bb688084.aspx

Advertisements
Categories: LINQ
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: