为什么 is 或 as 运算符的左侧不允许使用 lambda 和匿名方法?

why are lambdas & anonymous methods not allowed on the left side of the is or as operator?

Lambdas are not allowed on the left side of the is or as operator. MSDN

一个清晰的解释和一个真实的例子将不胜感激?

Lambda 没有类型,因此,使用检查值类型的运算符没有意义 没有类型

我怀疑这与以下案例无关:

Func<string> x = () => "";  
bool result = x is Func<string>;

但对于这种情况:

// This won't compile
if((() => "") is Func<string>)
{
}

...或:

// This won't compile too
Func<string> func = (() => "") as Func<string>;

Lambda 表达式和匿名方法本身没有类型,但它们在使用委托类型自动推断时很有用:

// C# compiler understands that the right part should be Func<string>
// because the expression signature and return value matches Func<string>
Func<string> func = () => "hello world";

MSDN 声明 isas 不能与匿名方法和 lambda 表达式一起使用,因为它们在被推断为某些实际委托类型或表达式树之前没有类型。