CS0052 fordítóhiba

Inkonzisztens akadálymentesség: a "type" mezőtípus kevésbé akadálymentes, mint a mező

A mező típusa nem lehet kevésbé akadálymentes, mint maga a mező, mert minden nyilvános szerkezetnek nyilvánosan hozzáférhető objektumot kell visszaadnia.

Példa

Az alábbi minta a CS0052-t hozza létre:

// CS0052.cs
public class MyClass2
{
    // The following line causes an error because the field, M, is declared
    // as public, but the type, MyClass, is private. Therefore the type is
    // less accessible than the field.
    public MyClass M;   // CS0052

    private class MyClass
    {
    }
    // One way to resolve the error is to change the accessibility of the type
    // to public.
    //public class MyClass
    // Another solution is to change the accessibility of the field to private.
    // private MyClass M;
}

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

Lásd még