Compiler Error CS1510

A ref or out argument must be an assignable variable

Only a variable can be passed as a ref parameter in a method call. A ref value is like passing a pointer.

The following sample generates CS1510:

// CS1510.cs
public class C
{
   public static int j = 0;

   public static void M(ref int j)
   {
      j++;
   }

   public static void Main ()
   {
      M (ref 2);   // CS1510, can't pass a number as a ref parameter
      // try the following to resolve the error
      // M (ref j);
   }
}

Community Additions

ADD
Show: