Wednesday, July 1, 2009

String Split for new line in C#

Today one of my friend faced problem in sorting. Spliting the new line('\r\n')
in the given text.

This is will be very use full for beginners.

Example:

string[] strSplit=new string[1];
strSplit[0]="\r\n";
string[] strarrayemail = txtEmail.Text.Split(strSplit,StringSplitOptions.RemoveEmptyEntries);
Array.Sort(strarrayemail);
txtEmail.Text =string.Empty;
foreach (string str in strarrayemail)
{
txtEmail.Text += str + "\r\n";
}