Fastest way to remove white spaces in string

后端 未结 13 1212
粉色の甜心
粉色の甜心 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 18:57

    Given the implementation of string.Replaceis written in C++ and part of the CLR runtime I'm willing to bet

    email.Replace(" ","").Replace("\t","").Replace("\n","").Replace("\r","");

    will be the fastest implementation. If you need every type of whitespace, you can supply the hex value the of unicode equivalent.

提交回复
热议问题