Trim() doesn't work!!
-
This code doesn't work for me:
String str = this.textBox1.Text;
String newStr = str.Trim();
MessageBox.Show(newStr);The MessageBox that appears contain the string WITH all white spaces!!! Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C# and C++!
-
This code doesn't work for me:
String str = this.textBox1.Text;
String newStr = str.Trim();
MessageBox.Show(newStr);The MessageBox that appears contain the string WITH all white spaces!!! Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C# and C++!
Trim only removes leading and trailing whitespace. It doesnt remove the spaces between words etc. Is that what you mean? -- David Wengier Sonork ID: 100.14177 - Ch00k
-
This code doesn't work for me:
String str = this.textBox1.Text;
String newStr = str.Trim();
MessageBox.Show(newStr);The MessageBox that appears contain the string WITH all white spaces!!! Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C# and C++!
****Rickard Andersson wrote: This code doesn't work for me: It worked for me :-) Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)
-
Trim only removes leading and trailing whitespace. It doesnt remove the spaces between words etc. Is that what you mean? -- David Wengier Sonork ID: 100.14177 - Ch00k
hm.. what I understod from my book it was suppose to do that... but okay! Thank ya! Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C# and C++!
-
****Rickard Andersson wrote: This code doesn't work for me: It worked for me :-) Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)
Nish - Native CPian wrote: It worked for me huh? Well I can compile it... but I missunderstod the use of Trim(). I thought it was suppose to remove all white spaces in the string! :) Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C# and C++!
-
This code doesn't work for me:
String str = this.textBox1.Text;
String newStr = str.Trim();
MessageBox.Show(newStr);The MessageBox that appears contain the string WITH all white spaces!!! Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C# and C++!
-
This code doesn't work for me:
String str = this.textBox1.Text;
String newStr = str.Trim();
MessageBox.Show(newStr);The MessageBox that appears contain the string WITH all white spaces!!! Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C# and C++!
Quote frpm MSDN ( I suggest you use it :) ) String.Trim Method Removes all occurrences of a set of specified characters from the beginning and end of this instance. Overload List Removes all occurrences of white space characters from the beginning and end of this instance.
public string Trim();
Removes all occurrences of a set of characters specified in a Unicode character array from the beginning and end of this instance.public string Trim(params char[]);
IOWString str = this.textBox1.Text; String newStr = str.Trim(' '); // note space char MessageBox.Show(newStr);
Hope this helps :)