Error del compilador CS0631

Actualización: noviembre 2007

Mensaje de error

ref y out no son válidos en este contexto
ref and out are not valid in this context

La declaración de una propiedad de indizador no puede incluir el uso de los parámetros ref u out.

Ejemplo

El código siguiente genera el error CS0631:

// CS0631.cs
public class MyClass
{
    public int this[ref int i]   // CS0631
    // try the following line instead
    // public int this[int i]
    {
        get
        {
            return 0;
        }
    }
}

public class MyClass2
{
    public static void Main()
    {
    }
}