共用方式為


編譯器錯誤 CS0834

更新:2007 年 11 月

錯誤訊息

Lambda 運算式必須要將運算式主體轉換為運算式樹狀架構。

轉譯為運算式樹狀架構的 Lambda 必須是運算式 Lambda,而陳述式 (Statement) Lambda 和匿名方法 (Anonymous Method) 只可以轉換為委派 (Delegate) 型別。

若要更正這個錯誤

  • 移除 Lambda 運算式中的陳述式。

範例

下列範例會產生 CS0834:

// cs0834.cs
using System;
using System.Linq;
using System.Linq.Expressions;

public class C
{
    public static int Main()
    {
        Expression<Func<int, int>> e = x => { return x; }; // CS0834
    }
}