我想学习使用构造函数在两个C#表单之间传递一个列表,如下所示。在第一种形式我做:在C#表单之间传递列表
List<Cat> myCatList;
//list populating function...
private void btnDisplay_Click(object sender, EventArgs e)
{
df = new DisplayForm(myCatList);
df.Show();
this.Hide();
}
在接下来的形式,我想接收数据,如下图所示:
List<Cat> catList;
public DisplayForm(List<Cat> catList)
{
InitializeComponent();
this.catList = catList;
}
但我总是得到一个错误的第二种形式的构造说:
错误1可访问性不一致:参数类型 'System.Collections.Generic.List < _05_WindowsFormsAppCat.Cat>' 比方法更少可访问的“_05_WindowsFormsAppCat.DisplayForm.DisplayForm(System.Collections.Generic.List < _05_WindowsFormsAppCa t.Cat>)'
任何想法?
显示Cat的定义。我敢打赌,这不是“公共” –