How to remove space from string in asp.net

{0 Comments}

To remove space from the string you can use replace method. There are two parameters which you have to pass to replace the space from the string. on is the character which you want to remove and other is the character which used in place of space. Following is the syntax which you can used to replace space or other character.

 C# |  copy code |? 
1
abc.Replace("", string.Empty);

following the complete syntax and output 

 C# |  copy code |? 
1
string abc = TextBox1.Text;
2
        string temp=abc.Replace(" ", string.Empty);
3
        Label1.Text = temp;

Leave a Comment

Your email address will not be published.