This documentation is archived and is not being maintained.

Compiler Error CS1501 

Error Message

No overload for method 'method' takes 'number' arguments

A call was made to a class method, but there is no form of the method that takes the necessary number of arguments.

CS1501 could occur if you are calling a method on a class in a referenced assembly and if that method has default values on one or more of its parameters. C# does not let you create methods with a default value on a parameter, but another language that targets the runtime might. If a parameter (in a method in a referenced assembly) has a default value, you must still call the method and explicitly pass all parameters.

CS1501 could occur when you allocate memory for a delegate; you must also specify the name of the method that the delegate represents, as shown in the second example below.

CS1501 also occurs if you attempt to instantiate a derived class that inherits from a base class that has no default constructor but does have a non-default constructor that takes one or more arguments. To correct the error, either supply a default constructor for the base class, or use the base (C# Reference) keyword to call the appropriate base class constructor, as shown in the third example below. For more information, see Using Constructors (C# Programmers Reference).

Example

The following sample generates CS1501.

// CS1501.cs
public class a
{
    // declare the following constructor to resolve this CS1501
    /*
    public a(int i)
    {
    }
    */

    public static void Main()
    {
        a aa = new a(2);   // CS1501
    }
}

The following sample generates CS1501.

// CS1501a.cs
using System;

delegate string func(int i);   // declare the delegate

class a
{
    static func dt;   // class member-field of the declared delegate type

    public static void Main()
    {
        dt = new func();   // CS1501
        // try the following line instead
        // dt = new func(z);   // this works
        x(dt);
    }

    public static string z(int j)
    {
        Console.WriteLine(j);
        return j.ToString();
    }

    public static void x(func hello)
    {
        hello(8);
    }
}

The following sample generates CS1501.

// CS1501b.cs
class Base
{
    public Base(string s)
    {
    }
}

class Derived : Base   
{ // CS1501
    public Derived(string s)
    {
    }

    // Try this instead:
    // public Derived(string s) : base(s)
    // {
    // }

    public static void Main()
    {
    }
}
Show: