Inconsistent accessibility: field type 'world' is less accessible than field 'frmSplashScreen

我的未来我决定 提交于 2019-12-18 03:04:39

问题


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?


回答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)




回答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



回答3:


you can't use private access specifier in that statement

    Public class world

will solve this problem




回答4:


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



来源:https://stackoverflow.com/questions/12990309/inconsistent-accessibility-field-type-world-is-less-accessible-than-field-fr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!