Answered by:
remove empty space

Question
-
remove emprty space in string
For example
Input: "Phone Number"
I want output: "PhoneNumber"
please resolve this problem
Monday, July 23, 2012 9:57 AM
Answers
-
Hi
string output = input.Replace(" ", "");
- Proposed as answer by Dave A Gordon Monday, July 23, 2012 10:02 AM
- Marked as answer by Jason Dot Wang Tuesday, July 31, 2012 9:08 AM
Monday, July 23, 2012 10:00 AM
All replies
-
Hi
string output = input.Replace(" ", "");
- Proposed as answer by Dave A Gordon Monday, July 23, 2012 10:02 AM
- Marked as answer by Jason Dot Wang Tuesday, July 31, 2012 9:08 AM
Monday, July 23, 2012 10:00 AM -
if you want to get rid of any kind of whitespace including " ", \t, \r \n and
others of the SpaceSepareator unicode category, try
string spaceless = RemoveWhiteSpaces("Phone Number"); static string RemoveWhiteSpaces(string input) { char[] chars = input.Where(c => !char.IsWhiteSpace(c)).ToArray(); return new string(chars); }
Chris
- Proposed as answer by insigniya Monday, July 23, 2012 10:45 AM
Monday, July 23, 2012 10:32 AM -
Use this code:
string name is input:
input.Trim();
It removes all the whitespaces
Sivalingam
Monday, July 23, 2012 11:38 AM -
Use this code:
string name is input:
input.Trim();
It removes all the whitespaces
Sivalingam
Monday, July 23, 2012 2:50 PM