C# Error
CS1620 – Argument {0} must be passed with the ‘{1}’ keyword
Reason for the Error & Solution
Argument ‘number’ must be passed with the ‘keyword’ keyword
This error occurs if you are passing an argument to a function that takes a or parameter and you don’t include the ref
or out
keyword at the point of call, or you include the wrong keyword. The error text indicates the appropriate keyword to use and which argument caused the failure.
The following sample generates CS1620:
// CS1620.cs
class C
{
void f(ref int i) {}
public static void Main()
{
int x = 1;
f(out x); // CS1620 – f takes a ref parameter, not an out parameter
// Try this line instead:
// f(ref x);
}
}