컴파일러 오류 CS0428
업데이트: 2007년 11월
오류 메시지
'Identifier' 메서드 그룹을 비대리자 형식 'type'(으)로 변환할 수 없습니다. 메서드를 호출하시겠습니까?
Cannot convert method group 'Identifier' to non-delegate type 'type'. Did you intend to invoke the method?
이 오류는 메서드 그룹을 비대리자 형식으로 변환하거나 괄호를 사용하지 않고 메서드를 호출하려 할 때 발생합니다.
예제
다음 샘플에서는 CS0428 오류가 발생하는 경우를 보여 줍니다.
// CS0428.cs
delegate object Del1();
delegate int Del2();
public class C
{
public static C Method() { return null; }
public int Foo() { return 1; }
public static void Main()
{
C c = Method; // CS0428, C is not a delegate type.
int i = (new C()).Foo; // CS0428, int is not a delegate type.
Del1 d1 = Method; // OK, assign to the delegate type.
Del2 d2 = (new C()).Foo; // OK, assign to the delegate type.
// or you might mean to invoke method
// C c = Method();
// int i = (new C()).Foo();
}
}