컴파일러 오류 CS1618

업데이트: 2007년 11월

오류 메시지

'method'은(는) Conditional 특성을 가지므로 이를 사용하여 대리자를 만들 수 없습니다.
Cannot create delegate with 'method' because it has a Conditional attribute

일부 빌드에서는 조건부 메서드가 없을 수도 있으므로 이를 사용하여 대리자를 만들 수 없습니다.

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

// CS1618.cs
using System;
using System.Diagnostics;

delegate void del();

class MakeAnError {
   public static void Main() {
      del d = new del(ConditionalMethod);   // CS1618
      // Invalid because on builds where DEBUG is not set, 
      // there will be no "ConditionalMethod".
   }
   // To fix the error, remove the next line:
   [Conditional("DEBUG")]
   public static void ConditionalMethod() 
   {
      Console.WriteLine("Do something only in debug");
   }
}