2 out of 11 rated this helpful - Rate this topic

Compiler Error CS1501

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.

The following sample generates CS1501.

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            ExampleClass ec = new ExampleClass();
            ec.ExampleMethod();
            ec.ExampleMethod(10);
            // The following line causes compiler error CS1501 because 
            // ExampleClass does not contain an ExampleMethod that takes
            // two arguments.
            ec.ExampleMethod(10, 20);
        }
    }

    // ExampleClass defines two methods, one that has no parameters and
    // one that has a single parameter.
    class ExampleClass
    {
        public void ExampleMethod()
        {
            Console.WriteLine("Zero parameters");
        }

        public void ExampleMethod(int i)
        {
            Console.WriteLine("One integer parameter.");
        }
    }
}
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Default parameters in C#
Since C# version 4.0, parameters with default values exist in C#, so the description ought to be updated. /JeppeSN


Edit by SJ at MSFT: You're right. I will update it. Thanks.