Inconsistent accessibility

前端 未结 2 1194
猫巷女王i
猫巷女王i 2021-01-01 21:27

I am getting the following error

Inconsistent accessibility: parameter type \'Db.Form1.ConnectionString\' is less accessible than method \'Db.Form1.B

相关标签:
2条回答
  • 2021-01-01 22:00

    Your ConnectionString type is not public, yet, a public method of a public class is using it as a parameter. You must also make the type public, for instance:

    // If it's a class
    public class ConnectionString { ... }
    
    0 讨论(0)
  • 2021-01-01 22:11

    As described here, classes and structs are private by default if no access modifier is specified. Where you have defined your struct as:

    struct ConnectionString
    {
        public string Provider;
        public string DataSource;
        public string UserId;
        public string Password;
        public string Database;
    }
    

    you need to instead define it as:

    public struct ConnectionString
    {
        public string Provider;
        public string DataSource;
        public string UserId;
        public string Password;
        public string Database;
    }
    
    0 讨论(0)
提交回复
热议问题