Compiler Error CS1501
Visual Studio 2008
Updated: July 2009
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.
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."); } } }