Compiler Error CS0206
TOC
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

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).

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
    }
}
Show:
© 2016 Microsoft