C# Error CS1593 – Delegate ‘{0}’ does not take {1} arguments

C# Error

CS1593 – Delegate ‘{0}’ does not take {1} arguments

Reason for the Error & Solution

Delegate ‘del’ does not take ‘number’ arguments

The number of arguments passed to a invocation does not agree with the number of parameters in the delegate declaration.

The following sample generates CS1593:

// CS1593.cs  
using System;  
delegate string func(int i);   // declare delegate  
  
class a  
{  
   public static void Main()  
   {  
      func dt = new func(z);  
      x(dt);  
   }  
  
   public static string z(int j)  
   {  
      Console.WriteLine(j);  
      return j.ToString();  
   }  
  
   public static void x(func hello)  
   {  
      hello(8, 9);   // CS1593  
      // try the following line instead  
      // hello(8);  
   }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...