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.

Example

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()  
        {  
        }  
    }  

See Also

C# Keywords
Access Modifiers
Accessibility Levels
Modifiers