【发布时间】:2012-07-24 18:30:56
【问题描述】:
我想以单独的标签显示字典中的值。我得到这样的字典:
Dictionary<string, int> counts = new Dictionary<string, int>();
foreach (string code in myCodeList)
{
if (!counts.ContainsKey(code))
{
counts.Add(code, 1);
}
else
{
counts[code]++;
}
}
//now counts contains the expected values
我想动态生成标签,因为counts 中的元素只能在运行时确定。
【问题讨论】:
-
我没有得到你的代码,为什么不只是 Label.Text=String.Concat(",",myList);
标签: c# dictionary label dynamically-generated