我收到以下错误
错误不一致的可访问性:字段类型“Project3_MineSweeper.DB”的可访问性低于字段“Project3_MineSweeper.Form2.db”
这是 DB.cs 中的代码
class DB
{
private string connectionString;
public string ConnectionString
{
get { return connectionString; }
}
private SqlConnection connection;
public SqlConnection Connection
{
get { return connection; }
}
public DB()
{
connectionString="Data Source=NGFAJAR-PC\\FAJAR;Initial Catalog=DB;Integrated Security=True";
connection = new SqlConnection(connectionString);
}
}
这是Form2.cs的代码
public partial class Form2 : Form
{
public DB db; //it's here where I am getting the error
private Form3 form3;
public Form2()
{
db = new DB();
InitializeComponent();
}
...
}
最后,Form3.cs
public partial class Form3 : Form
{
private Form2 form2;
public Form3()
{
InitializeComponent();
}
public void loadData()
{
DataTable dt = form2.db.GetData();
dgvScore.DataSource = dt;
}
}
怎么了?我应该怎么做才能解决它?感谢您的关注和帮助。