Search code examples
c#accessibilitypublic

Why do I get an Inconsistent Accessibility error, "parameter type is less accessible than method"?


I have the following Class, RoomMonitor, set up as so:

class RoomMonitor {
    public RoomMonitor (Account acc) {
           // Init stuff
    }
}

And the Account class is set up as:

class Account {
    public Account (DataRow row) {
           // Init stuff
    }
}

This error shouldn't be happening then since both classes are public, right? And yet, I get the error:

Inconsistent accessibility: parameter type 'Hotel_Manager.Objects.Account' is less accessible than method 'Hotel_Manager.RoomMonitor.RoomMonitor


Solution

  • The code you have shown looks like the constructors for the two classes. The class declarations themselves should both be public. For example:

    public class RoomMonitor
    

    If they are not, you will get this error.