Why string.IsNullOrWhiteSpace(“\0”) is false

前端 未结 6 1890
不思量自难忘°
不思量自难忘° 2021-01-18 13:17

I faced a problem where invisible character \\0 which is pretty like a \'white space\' not considered as white space by the string.IsNullOrWhiteSpace method. I

6条回答
  •  没有蜡笔的小新
    2021-01-18 13:47

    You could replace all \0 characters with the space character, and then check for whitespace.

    string.IsNullOrWhiteSpace("\0".Replace('\0', ' ');
    

提交回复
热议问题