The Beauty of LINQ

I was recently working with an RDP settings file and its myriad of settings and corresponding lines. I couldn’t find what I needed so I thought it would be nice to sort the lines. I am sure there are utilities out there that can quickly sort a bunch of text lines but like most programmers, I thought it best that I develop my own solution. So I fired up VS and created a new Windows Forms project, added a standard TextBox and Button control to my form and wired up the following OnClick event:

private void ButtonSort_Click(object sender, EventArgs e)

{

    TextBoxMain.Lines = TextBoxMain.Lines

        .OrderBy(s => s)

        .ToArray();

}

Just too simple. Man I love LINQ!

Comments

Popular posts from this blog

Yet once more into the breech (of altered programming logic)

Simple WP7 Mango App for Background Tasks, Toast, and Tiles: Code Explanation

How to convert SVG data to a Png Image file Using InkScape