编译器错误 CS1706
更新:2007 年 11 月
错误消息
表达式不能包含匿名方法或 lambda 表达式
不能在表达式内插入匿名方法。
更正此错误
- 在表达式中使用规则 delegate。
示例
下面的示例生成 CS1706。
// CS1706.cs
using System;
delegate void MyDelegate();
class MyAttribute : Attribute
{
public MyAttribute(MyDelegate d) { }
}
// Anonymous Method in Attribute declaration is not allowed.
[MyAttribute(delegate{/* anonymous Method in Attribute declaration */})] // CS1706
class Program
{
}