Fastest way to remove white spaces in string

后端 未结 13 1145
粉色の甜心
粉色の甜心 2020-11-27 18:39

I\'m trying to fetch multiple email addresses seperated by \",\" within string from database table, but it\'s also returning me whitespaces, and I want to remove the whitesp

相关标签:
13条回答
  • 2020-11-27 19:15

    I haven't done performance testing on this, but it's simpler than most of the other answers.

    var s1 = "\tstring \r with \t\t  \nwhitespace\r\n";
    var s2 = string.Join("", s1.Split());
    

    The result is

    stringwithwhitespace
    
    0 讨论(0)
提交回复
热议问题