Friday, January 25, 2008
« Seattle Code Camp | Main | Seattle Code Camp 2008 at Digipen »

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!

LINQ | Andy
Friday, January 25, 2008 2:01:37 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  |  Related posts:
Fuse Extension Method
Compare IEnumerable (a still better option)
Compare Byte Arrays
Comma Delimited String From An Array using LINQ

Friday, January 25, 2008 7:42:48 PM (Pacific Standard Time, UTC-08:00)
TextBox.Lines huh? I had no idea. Goes to show how many Windows Forms projects I've worked on lately. ;-)

Pretty slick Andy.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview