我单位300多人,在一个人名单中,按人名为每个人建立一个泛型数组,如:
List<personDayRecord> mydayrecordList = new List<personDayRecord>();但如何从人名单中读出一个人名,就建立一个泛型数组呢?
List<personDayRecord> 张三 = new List<personDayRecord>();List<personDayRecord> 李四 = new List<personDayRecord>();List<personDayRecord> 王五 = new List<personDayRecord>();
List<personDayRecord> mydayrecordList = new List<personDayRecord>();但如何从人名单中读出一个人名,就建立一个泛型数组呢?
List<personDayRecord> 张三 = new List<personDayRecord>();List<personDayRecord> 李四 = new List<personDayRecord>();List<personDayRecord> 王五 = new List<personDayRecord>();
{
List<personDayRecord> MyPersonName = new List<personDayRecord>();
}我的这种写法报错,请问正确的写法。
private void Form1_Load(object sender, EventArgs e)
{
IList<string> names = new List<string>();
names.Add("张三");
names.Add("李四");
names.Add("王五"); IDictionary<string, List<string>> dicts = new Dictionary<string, List<string>>(); foreach(string s in names)
{
dicts.Add(s,this.GetList());
} } /// <summary>
/// 这个函数里写你的数组代码
/// </summary>
/// <returns></returns>
private List<string> GetList()
{
return new List<string>();
}