更新:2007 年 11 月
错误消息
表达式目录树不能包含匿名方法表达式。
表达式目录树只能包含表达式。匿名方法只能表示语句。
更正此错误
- 不要尝试用语句创建表达式目录树。
示例
下面的代码生成 CS1945:
// cs1945.cs
using System;
using System.Linq.Expressions;
public delegate void D();
class Test
{
static void Main()
{
Expression<Func<int, Func<int, bool>>> tree = (x => delegate(int i) { return true; }); // CS1945
}
}