I'm looking for a efficient way for removing all of the white spaces in an string. I have checked replace (replace(' ','')) but I'm looking for a more efficient way. I'd appreciate the help.
- 
        2stackoverflow.com/questions/6219454/…Nagaraj S– Nagaraj S2020-02-05 07:25:36 +00:00Commented Feb 5, 2020 at 7:25
 - 
        4Does this answer your question? Efficient way to remove ALL whitespace from String?Ajit Panigrahi– Ajit Panigrahi2020-02-05 07:29:39 +00:00Commented Feb 5, 2020 at 7:29
 - 
        Do you want to remove whitespace globally? then you can be used trim model binder from link stackoverflow.com/a/1734025/9334498Yasin Sunni– Yasin Sunni2020-02-05 07:35:33 +00:00Commented Feb 5, 2020 at 7:35
 - 
        are you using EntityFramwork??Shakir Ahamed– Shakir Ahamed2020-02-05 07:40:31 +00:00Commented Feb 5, 2020 at 7:40
 - 
        Use the dupe Luke, it has many answers. Answers with benchmark of other answer. It doesn't blindly claim red car are faster. It provides tests cases and benchmark.Drag and Drop– Drag and Drop2020-02-05 08:00:38 +00:00Commented Feb 5, 2020 at 8:00
 
                    
                        
                    
                 | 
            
                Show 1 more comment
            
        
         
    1 Answer
You may use Regular Expression.
For example:
var result=System.Text.RegularExpressions.Regex.Replace(input, @"\s+", "");
Input is your string
See more Removing whitespaces using C#
2 Comments
Corak
 "must" is a strong word here. You can. Alternatively, you could also use something like 
  new string(input.Where(c => !char.IsWhiteSpace(c)).ToArray()). Since Regex isn't magic, it probably does something very similar to that.Ramil Aliyev 007
 thanks you for comment, i already edit @Corak