什么是“is”运算符后跟空双括号?

ded*_*cos 0 c#

这个表达式中这些空双括号的作用是什么?

record MyRecord(int i, int? j);

public void MyMethod()
{
    MyRecord myVar = new(10);

    if (myVar is { i: { } })
    {
          // ?
    }

    if (myVar is { j: { } })
    {
          // ?
    }
}
Run Code Online (Sandbox Code Playgroud)

我在参考页中没有找到。

这只是另一种检查方式吗null

Miq*_*Miq 6

它用于检查 c# 7 中是否不为 null。它利用模式匹配。从 c# 9 开始,不再需要它,因为您可以使用is not null