Compiler Error CS1620
Argument 'number' must be passed with the 'keyword' keyword
This error occurs if you are passing an argument to a function that takes a ref or out 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);
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: