共用方式為


編譯器錯誤 CS1951

更新:2007 年 11 月

錯誤訊息

運算式樹狀架構 Lambda 可能不包含 out 或 ref 參數。

運算式樹狀架構只會將運算式表示為資料結構。當您以傳址 (By Reference) 方式傳遞參數時,沒有辦法能夠表示需要的特定記憶體位置。

若要修正這個錯誤

  • 唯一的選擇是移除委派 (Delegate) 定義中的 ref 修飾詞 (Modifier),並以傳值 (By Value) 方式傳入參數。

範例

下列範例會產生 CS1951:

// cs1951.cs
using System.Linq;
public delegate int TestDelegate(ref int i);
class Test
{
    static void Main()
    {
        System.Linq.Expressions.Expression<TestDelegate> tree1 = (ref int x) => x; // CS1951
    }
}

請參閱

概念

運算式樹狀架構