namespace Project_bill
{
public partial class MainForm : Form
{
private List<myClass> _lstChanel = new List<myClass>();
private void MainForm_Load(object sender, EventArgs e)
{
//对_lstChanel的添加或删除
}
publc List<myClass> rtnList()
{
return this._lstChanle;
}
}
class myClass
{
}
}
这里会对rtnList报一个Inconsistent accessibility: return type 'System.Collections.Generic.List<Project_bill.myClass>' is less accessible than method 'Project_bill.MainForm.rtnList()'
请问这是哪里的问题?
------解决思路----------------------
myClass这个类要设置成public,不然外部访问不到这个类,在访问不到这个类的情况下,怎么理解publc List<myClass>呢
------解决思路----------------------
private List<myClass> _lstChanel = new List<myClass>();
->
public List<myClass> _lstChanel = new List<myClass>();
根源在于,你的变量是个私有变量,可你在公共函数里返回它,它是不可被外部访问的,你没法返回它