我在一些C#源代码中发现了以下的一行:
if(!(context.Compilation.GetTypeByMetadataName("Xunit.FactAttribute")
is { } factAttribute))
这里还有另一个:
if(!(diagnostic.Location.SourceTree is { } tree))
在is
运算符后面的花括号({ }
)的含义是什么?
我在一些C#源代码中发现了以下的一行:
if(!(context.Compilation.GetTypeByMetadataName("Xunit.FactAttribute")
is { } factAttribute))
这里还有另一个:
if(!(diagnostic.Location.SourceTree is { } tree))
在is
运算符后面的花括号({ }
)的含义是什么?
if (iterator.Read() is {} item)
。 - d.k.