2015-04-16 105 views
0

獲取以下錯誤。我試圖在點擊第一個表單上的按鈕後跳轉到新表單。我需要傳遞一個類對象的列表。不一致的可訪問性:參數類型不易訪問

錯誤1可訪問性不一致:參數類型 'System.Collections.Generic.List' 比方法更少可訪問 'Preferred_Customer.AddCustomer.AddCustomer(System.Collections.Generic.List)' C:\用戶\羅恩\文件\視覺 工作室2013 \項目\優選的客戶\優選 客戶\ 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; 

    } 

有人能說出我錯過了什麼嗎?

+0

「PrefferedCustomer」類定義在哪裏?如果它不公開,那就需要。 –

+0

PreferredCustomer類是否爲私人類? – rjdevereux

回答

2

PrefferedCustomer從內部更改爲公共。 (我猜PrefferedCustomer是內部的,除非內的另一個類的聲明) 或改變AddCustomerinternal匹配可進入等級

internal partial class AddCustomer : Form 
1

這個錯誤來自試圖在一個水平暴露在一個類的類型更「開放「而不是它宣佈的那個。例如:

internal interface ISomethingManager { 
    // ... 
} 

public interface IDoSomething { 
    public void DoSomething(ISomethingManager manager); 
} 

在這個例子中ISomethingManager是內部的,但你在公共​​揭露它作爲一個方法參數。如果另一個組合想要撥打IDoSomething.DoSomething(),則需要知道約ISomethingManager,這在內部是不可能的。

相關問題