Check if string is empty or all spaces in C#

前端 未结 5 839
说谎
说谎 2020-12-09 14:32

How to easily check if a string is blank or full of an undetermined amount of spaces, or not?

5条回答
  •  再見小時候
    2020-12-09 15:19

    Try use LinQ to solve?

    if(from c in yourString where c != ' ' select c).Count() != 0)
    

    This will return true if the string is not all spaces.

提交回复
热议问题