这个“!string”是什么意思?

What does this "!string" mean?

我正在工作场所浏览一个旧代码库以记录它并将其重新用于其他项目。 图书馆根本没有记录(甚至没有评论),但这没什么大不了的。

我发现了这个奇怪的语法,但我无法在网上找到它的解释...

public bool Validate()
    {
        return !string.IsNullOrWhiteSpace(Code) && !string.IsNullOrWhiteSpace(State);
    }

我知道感叹号是否定运算符,但它只能与布尔变量一起使用。怎么可能说 not(string)? string 关键字之前的感叹号是什么意思?工具提示也没有帮助..

这是标准的逻辑非运算符。

!表示 NOT,如

**Is `Code` is not a NULL or WhiteSpace**
And
**Is `State` is not a NULL or WhiteSpace**

!意思不是。 IsNullOrWhiteSpace 是 String 的静态方法,其中 returns 是一个布尔值,因此代码返回 'Code' 和 'State' 是否都有值。