Share via


Compiler Error CS0206

A property or indexer may not be passed as an out or ref parameter

A property is not available to be passed as a ref or out parameter. For more information, see Passing Parameters (C# Programming Guide).

Example

The following sample generates CS0206:

// CS0206.cs
public class MyClass
{
    public static int P
    {
        get
        {
            return 0;
        }
        set
        {
        }
    }

    public static void MyMeth(ref int i)
    // public static void MyMeth(int i)
    {
    }

    public static void Main()
    {
        MyMeth(ref P);   // CS0206
        // try the following line instead
        // MyMeth(P);   // CS0206
    }
}