开发者

Why does this C# constructor produce an inconsistent accessibility error?

I get an accessibility error

Inconsistent accessibility: parameter type 'FoolballLeague.FootballLeagueDatabase' is less accessible than method 'FoolballLeague.MainMenu.MainMenu(FoolballLeague.FootballLeagueDatabase)'

C:\Users\achini\Desktop\FootballLeague\FootballLeague\MainMenu.cs

//public MainMenu(FootballLeagueDatabase footballLeagueDatabaseIn) //{ //InitializeComponent(); /开发者_运维百科/footballLeagueDatabase = footballLeagueDatabaseIn; //}

When I run this code

public partial class MainMenu : Form
{
    FootballLeagueDatabase footballLeagueDatabase;
    Game game;
    Login login;

    public MainMenu()
    {
        InitializeComponent();
        changePanel(1);
    }

    public MainMenu(FootballLeagueDatabase footballLeagueDatabaseIn)
    {
        InitializeComponent();
        footballLeagueDatabase = footballLeagueDatabaseIn;
    }
}

And I don't know why. What am I missing? What does accessibility mean?


Make the definition of FootballLeagueDatabase public where it is declared, that should help.


Make FoolballLeague.FootballLeagueDatabase public


The FootballLeagueDatabase class must be public to allow a client of your code to call the MainMenu() method. The error says that it isn't public.

Put "public" in front of the class declaration. Or consider if you really intended to make MainMenu() public. It quacks like a method that should be internal.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜