How to trim whitespace between characters

后端 未结 9 1868
天命终不由人
天命终不由人 2020-12-05 07:17

How to remove whitespaces between characters in c#?

Trim() can be used to remove the empty spaces at the beginning of the string as well as at the end.

9条回答
  •  Happy的楠姐
    2020-12-05 07:49

    var str="  c sharp  "; str = str.Trim();
            str = Regex.Replace(str, @"\s+", " ");  ///"c sharp"
    

提交回复
热议问题