Method 1
static Regex whitespace = new Regex(@"\s+");
private void btnOK_Click(object sender, EventArgs e)
{
string str = txt1.Text;
txt2.Text = whitespace.Replace(str,
"");
}
Method 2
private void btnOK_Click(object sender, EventArgs e)
{
string str = txt1.Text;
txt2.Text = string.Join("",
str.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries));
}
No comments:
Post a Comment