我有一個結構數組。我如何將它們全局存儲在GlobalVariables.cs中?當我嘗試時,它會給出一個錯誤,說明它由於其保護級別而無法訪問。請幫忙!在C中的GlobalVariables.cs中存儲一個結構數組#
這裏是GlobalVariables.cs代碼:
public class GlobalVariables
{
List<Employee[]> persons = new List<Employee[]>();
}
這裏是表單代碼:
List<Employee> persons = new List<Employee>()
{
new Employee { Name = "alfred", Id = 203476, Authority = "1" },
new Employee { Name = "barbara", Id = 182856, Authority = "4" },
new Employee { Name = "chris", Id = 398046, Authority = "2" },
};
這裏是員工結構:
public struct Employee
{
public string Name;
public int Id;
public string Authority;
}
Employee結構在內部類中聲明爲嵌套類型嗎? –