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
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for