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
Share:
82,715

Related videos on Youtube

user1761786
Author by

user1761786

public int add(int a,int b) { return a+b; }

Updated on April 25, 2020

Comments

  • user1761786
    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
      Guffa over 11 years
      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...
    • rhavin
      rhavin over 7 years
      Downvoted for not explaining anything and polluting search results
  • Leniel Maccaferri
    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
    Leniel Maccaferri over 11 years
    Well 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
    Leniel Maccaferri over 11 years
    Wait a long time for what? :)
  • user1761786
    user1761786 over 11 years
    for the error to dissapear in the error window in visual studio
  • amr osama
    amr osama about 9 years
    do this for the class and any base class of it
  • ElDoRado1239
    ElDoRado1239 almost 7 years
    While 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
    toscanelli over 6 years
    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.
  • kolexinfos
    kolexinfos about 6 years
    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.
  • ulkas
    ulkas about 5 years
    in my case it was the opposite: i had to change from public into private ftw