C# Error CS1620 – Argument {0} must be passed with the ‘{1}’ keyword

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);  
    }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...