コンパイラ エラー CS1706

更新 : 2007 年 11 月

エラー メッセージ

式に匿名メソッドまたはラムダ式を含めることはできません

式の内部に匿名メソッドを挿入することはできません。

このエラーを解決するには

  • 式の中では、通常の 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
{
}