Inconsistent accessibility: field type 'world' is less accessible than field 'frmSplashScreen
82,715
Solution 1
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)
Solution 2
This can also happen when you have not initialized your class "world" as public
you should do :
public class world
Instead of :
class world
Related videos on Youtube
Comments
-
user1761786 about 4 years
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?
-
Guffa over 11 yearsCan you show more of the actual code? Judging from the error message the
frmSplashScreen
class is not actually public, or not actually a class... -
rhavin over 7 yearsDownvoted for not explaining anything and polluting search results
-
-
Leniel Maccaferri over 11 years... you removed your comment, but you got a different error. It's like the first error. You must change
time2Craft
to public. -
Leniel Maccaferri over 11 yearsWell looks like you have inconsistency throughout your classes' definitions. To help you more I need to see the code and the error messages.
-
Leniel Maccaferri over 11 yearsWait a long time for what? :)
-
user1761786 over 11 yearsfor the error to dissapear in the error window in visual studio
-
amr osama about 9 yearsdo this for the class and any base class of it
-
ElDoRado1239 almost 7 yearsWhile this would probably remove the error message, it's more of a hotfix than a real solution - the other answer resolves the main issue. But I understand OP didn't really describe his full situation clearly.
-
toscanelli over 6 yearsTake 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.
-
kolexinfos about 6 yearsThis 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.
-
ulkas about 5 yearsin my case it was the opposite: i had to change from public into private ftw