Export (0) Print
Expand All
Expand Minimize
3 out of 44 rated this helpful - Rate this topic

Compiler Error CS1502 

Error Message

The best overloaded method match for 'declaration' has some invalid arguments

This error occurs when the argument types being passed to the method do not match the parameter types of that method. If the called method is overloaded, then none of the overloaded versions has a signature that matches the argument types being passed.

To resolve this problem, do one of the following:

  • Double-check the types of the arguments being passed. Make sure that they match the arguments of the method being called.

  • If appropriate, convert any mismatched parameters using the System.Convert Class.

  • If appropriate, cast any mismatched parameters to match the type that the method is expecting.

  • If appropriate, define another overloaded version of the method to match the parameter types that are being sent.

The following sample generates CS1502:

// CS1502.cs
namespace x
{
   public class a
   {
      public a(char i)
      // try the following constructor instead
      // public a(int i)
      {
      }

      public static void Main()
      {
         a aa = new a(2222);   // CS1502
      }
   }
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.