string str = ""; string strInput = "Hi dear"; foreach (char c in strInput) { str += (c.ToString() == " " ? "" : c.ToString()); } MessageBox.Show(str);
Regards, Raja, USA
Thanks Pavan Kumar Mark Answer if this fits the need
string s = "Hello dear \n How are you?"; //Removes the space, tab and line break string d=Regex.Replace(s,@"[\s]",""); Console.WriteLine(d); /* * Output is HellodearHowareyou? */ // Removes the space and tab d = Regex.Replace(s, @"[ \t\r]", ""); Console.WriteLine(d); /* Output is Hellodear Howareyou? */
Thanks Ambily K K http://ambilykk.com/
Syed Shakeer Hussain
Login to post response