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

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...