Remove all whitespace from C# string with regex

前端 未结 7 1497
遇见更好的自我
遇见更好的自我 2020-12-25 10:18

I am building a string of last names separated by hyphens. Sometimes a whitespace gets caught in there. I need to remove all whitespace from end result.

Sample strin

7条回答
  •  礼貌的吻别
    2020-12-25 10:47

    Instead of a RegEx use Replace for something that simple:

    LastName = LastName.Replace(" ", String.Empty);
    

提交回复
热议问题