我如何检查我的字符串中是否有任何内容?

-3 c# visual-studio-2015

我看到有人问"如何检查我的字符串中是否有特定的文字?"

我想知道如何检查字符串中是否有任何内容.

Mar*_*ndl 7

您可以使用静态string.IsNullOrEmpty方法:

var test = string.Empty
if (string.IsNullOrEmpty(test))
{
    // There is nothing in the string or its null
}
Run Code Online (Sandbox Code Playgroud)