컴파일러 오류 CS0035

업데이트: 2007년 11월

오류 메시지

'operator' 연산자가 모호하여 'type' 형식의 피연산자에 사용할 수 없습니다.
Operator 'operator' is ambiguous on an operand of type 'type'

컴파일러에 사용할 수 있는 변환이 두 개 이상 있어 연산자를 적용할 변환을 알 수 없습니다. 자세한 내용은 Templated User Defined Conversions변환 연산자(C# 프로그래밍 가이드)를 참조하십시오.

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

// CS0035.cs
class MyClass
{
   private int i;

   public MyClass(int i)
   {
      this.i = i;
   }

   public static implicit operator double(MyClass x)
   {
      return (double) x.i;
   }

   public static implicit operator decimal(MyClass x)
   {
      return (decimal) x.i;
   }
}

class MyClass2
{
   static void Main()
   {
      MyClass x = new MyClass(7);
      object o = - x;   // CS0035
      // try a cast:
      // object o = - (double)x;
   }
}