Share via


컴파일러 오류 CS1662

업데이트: 2007년 11월

오류 메시지

무명 메서드 블록의 반환 형식 중 일부를 암시적으로 대리자 반환 형식으로 변환할 수 없으므로 무명 메서드 블록을 'delegate type' 대리자 형식으로 변환할 수 없습니다.
Cannot convert anonymous method block to delegate type 'delegate type' because some of the return types in the block are not implicitly convertible to the delegate return type

이 오류는 무명 메서드 블록의 return 문에 대리자 반환 형식으로 암시적으로 변환할 수 없는 형식이 있는 경우에 발생합니다.

다음 샘플에서는 CS1662 오류가 발생하는 경우를 보여 줍니다.

// CS1662.cs

delegate int MyDelegate(int i);

class C
{

  public static void Main()
  {
     MyDelegate d = delegate(int i) { return 1.0; };  // CS1662
     // Try this instead:
     // MyDelegate d = dekegate(int i) { return (int)1.0; };
  }
}