得到以下错误 . 我在点击第一张表格上的按钮后尝试跳转到新表格 . 我需要传递一个类对象列表 .
错误1可访问性不一致:参数类型'System.Collections.Generic.List'不如方法'Preferred_Customer.AddCustomer.AddCustomer(System.Collections.Generic.List)'C:\ Users \ Ron \ Documents \ Visual Studio 2013 \ Projects \ Preferred Customer \ Preferred Customer \ AddCustomer.cs 18 16首选客户
这是创建表单的代码;
private void addCustomerButton_Click(object sender, EventArgs e)
{
AddCustomer myAddCustomer = new AddCustomer(preferredCustomerList);
myAddCustomer.ShowDialog();
}
这是AddCustomer的代码;
namespace Preferred_Customer
{
public partial class AddCustomer : Form
{
private List<PreferredCustomer> addCustomerList;
public AddCustomer(List<PreferredCustomer> inPreferredCustomerList)
{
InitializeComponent();
addCustomerList = inPreferredCustomerList;
}
有人能说出我错过的东西吗?
2 回答
将
PrefferedCustomer
从内部更改为公共 . (我猜PrefferedCustomer
是内部的,除非在另一个类声明中)或者将AddCustomer
更改为internal
以匹配辅助功能级别这个错误来自于尝试在一个类中公开一个类型,而这个类的级别比它声明的级别更“开放” . 例如:
在此示例中,
ISomethingManager
是内部的,但您将其公开为publicIDoSomething
中的方法参数 . 如果另一个程序集想要调用IDoSomething.DoSomething()
,则需要知道ISomethingManager
,这在内部时是不可能的 .