Friday, January 25, 2008

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)



Just too simple. Man I love LINQ!

No comments:

Post a Comment