30

I have this error called Inconsistent accessibility:

field type 'world' is less accessible than field 'frmSplashScreen'

In my code there is a public partial class called frmSplashScreen

There is also a public class called world

The line that caused the error was:

private world currentWorld; 

The above line is in the class frmSplashScreen

What is causing the problem?

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
user1761786
  • 321
  • 1
  • 3
  • 6
  • 2
    Can you show more of the actual code? Judging from the error message the `frmSplashScreen` class is not actually public, or not actually a class... – Guffa Oct 20 '12 at 16:19
  • Downvoted for not explaining anything and polluting search results – rhavin Mar 26 '17 at 09:10

4 Answers4

77

This can also happen when you have not initialized your class "world" as public

you should do :

public class world

Instead of :

class world
BasssS
  • 921
  • 1
  • 6
  • 5
  • 1
    do this for the class and any base class of it – amr osama Jul 05 '15 at 08:46
  • 1
    Take into account that any class is "internal" by default in C#. That is the reason you need to specify "public". Great answer, by the way. – toscanelli Oct 09 '17 at 12:32
  • This resolved my issue, I was busy staring at the fields that I was returning from the method, not taking into cognizance the class that was being returned. – kolexinfos May 25 '18 at 11:12
25

Generally this happens because your field is private. You must change it to public:

public world currentWorld;

For more on this, take a look here: Restrictions on Using Accessibility Levels (C# Reference)

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
0

also , I got such an error with public access modifier. The solution was to add {get;set;} getter and setter to properties

e0x3
  • 131
  • 1
  • 1
  • 14
0

you can't use private access specifier in that statement

    Public class world

will solve this problem

manoj
  • 1