컴파일러 오류 CS0564

업데이트: 2007년 11월

오류 메시지

오버로드된 시프트 연산자의 첫 번째 피연산자는 포함하는 형식과 동일한 형식이어야 하며 두 번째 피연산자는 정수 형식이어야 합니다.
The first operand of an overloaded shift operator must have the same type as the containing type, and the type of the second operand must be int

형식이 올바르지 않은 피연산자를 사용하여 시프트 연산자(<< 또는 >>)를 오버로드하려고 했습니다. 첫 번째 피연산자는 포함하는 형식이어야 하고 두 번째 피연산자는 int 형식이어야 합니다.

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

// CS0564.cs
using System;
class C
{
   public static int operator << (C c1, C c2) // CS0564
// To correct, change second operand to int, like so:
// public static int operator << (C c1, int c2)
   {
      return 0;
   }
   static void Main() 
   {
   }
}