Compiler error ยท error CS1503
Argument N: cannot convert from 'X' to 'Y'
The value you handed the method does not fit the parameter's type. It's the argument-position sibling of CS0029 โ same idea, different location.
See it happen
void ShowScore(int score)
{
Console.WriteLine("Score: " + score);
}
ShowScore("ninety"); // the parameter is int โ this is text
Read the diagnostic as three facts: which argument (position 1), the type you supplied (string), the type the parameter wants (int). Fixing it means closing that gap on purpose.
Fix 1: convert before passing
void ShowScore(int score)
{
Console.WriteLine("Score: " + score);
}
ShowScore(int.Parse("90")); // deliberate conversion: text โ number
Fix 2: let the method accept what you have
Sometimes the signature is the thing that's wrong. If the method only ever prints the value, a string parameter is honest:
void ShowScore(string score) // accepts what callers actually have
{
Console.WriteLine("Score: " + score);
}
ShowScore("ninety");
Fix 3: the overload trap
When several overloads exist, the compiler picks by argument types. If none matches exactly, you get CS1503 (or CS1501 for count mismatches):
void Log(int value) { โฆ }
void Log(string text) { โฆ }
Log(42); // โ int overload
Log("done"); // โ string overload
Log(4.2); // โ no Log(double) exists โ CS1503
Fix the call (Log((int)4.2) or Log(4.2.ToString())) โ or add the missing overload.
Fix 4: number vs number, the lossy case
Passing a double where an int is expected would silently drop the fraction, so C# refuses โ that's this same family of error, and the fix is an explicit cast:
void ShowItems(int count)
{
Console.WriteLine("Items: " + count);
}
double exact = 3.7;
ShowItems((int)exact); // explicit: "I know, truncate it"
Frequently asked
What does CS1503 mean?
The argument you passed does not match the parameter's type. The message names the position and both types. Pass a value of the right type, convert explicitly, or change the parameter type.
Difference from CS0029?
CS0029 is the assignment version (int x = "5";); CS1503 is the method-argument version. Same fix, different location.
Checklist
- Note the argument position the message names โ count from the left starting at 1.
- Compare the two types side by side. Is one text and the other numeric?
- Convert at the call site (
int.Parse,.ToString(),(int)) or fix the signature. - If overloads exist, make sure your argument types match one of them exactly.