컴파일러 오류 CS0834

업데이트: 2007년 11월

오류 메시지

람다 식에는 식 트리로 변환되는 식 본문이 있어야 합니다.
A lambda expression must have an expression body to be converted to an expression tree.

식 트리로 변환되는 람다는 식 람다여야 합니다. 문 람다 및 익명 메서드는 대리자 형식으로만 변환할 수 있습니다.

이 오류를 해결하려면

  • 람다 식에서 문을 제거합니다.

예제

다음 예제에서는 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
    }
}