Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Error CS0052
Collapse the table of content
Expand the table of content

Compiler Error CS0052

Inconsistent accessibility: field type 'type' is less accessible than field 'field'

The type of a field cannot be less accessible than the field itself because all public constructs must return a publicly accessible object.

The following sample generates CS0052:

// 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()
© 2015 Microsoft