Edit

Share via


Compiler Error CS0123

No overload for 'method' matches delegate 'delegate'

An attempt to create a delegate failed because the correct signature was not used. Instances of a delegate must be declared with the same signature as the delegate declaration.

You can resolve this error by adjusting either the method or delegate signature. For more information, see Delegates.

The following sample generates CS0123.

C#
// CS0123.cs  
delegate void D();  
delegate void D2(int i);  
  
public class C  
{  
   public static void f(int i) {}  
  
   public static void Main()  
   {  
      D d = new D(f);   // CS0123  
      D2 d2 = new D2(f);   // OK  
   }  
}