以下列表是在名为“实体”的类中创建的,它们是私有的。我想退回它们(并在另一个班级中使用)我可以通过以下方式做些什么:
public List<string> getCMList()
{
return exceptionsCM;
}
但是如果有 10 个列表,我必须为所有这些列表编写一个公共的“get”方法。是否可以编写一个将字符串作为输入并返回该列表的方法?应该类似于..
public List<string> getList(.....)
{
return exceptionCM;
} //if we call getList(exceptionCM).
exceptionsCM = new List<string>();
exceptionsCM.Add("CM12");
exceptionsCM.Add("CM701");
exceptionsCM.Add("CM901/CM30");
exceptionsCM.Add("CM901K");
exceptionsCM.Add("CM1101");
exceptionsCM.Add("CM1101K");
//List with Multi Mill exceptions, they are included in the new MultiB
exceptionsMultiB = new List<string>();
exceptionsMultiB.Add("Multi650/450");
exceptionsMultiB.Add("Multi660/630");
exceptionsMultiB.Add("Multi650/800");
exceptionsMultiB.Add("Multi650/1000");
//List with Multi Mill exceptions, they are included in the new Multi01
exceptionsMulti01 = new List<string>();
exceptionsMulti01.Add("Multi301");
exceptionsMulti01.Add("Multi601");
exceptionsMulti01.Add("Multi801");
exceptionsMulti01.Add("Multi1001");