110,538
社区成员
发帖
与我相关
我的任务
分享
Dictionary<string, decimal> maxgoods = new Dictionary<string, decimal>();
maxgoods.Add("1", 258);
maxgoods.Add("2", 152);
ArrayList newgoodslist = new ArrayList();
newgoodslist.Add(maxgoods);
maxgoods.Clear();
foreach (Dictionary<string, decimal> item in newgoodslist)
{
// maxgoods.Clear() 后 item 为何为空 ,有没有办法不为空
foreach (KeyValuePair<string, decimal> litem in item)
{
MessageBox.Show(litem.Key + "===" + litem.Value.ToString() + "||");
}
}
ArrayList newgoodslist = new ArrayList();
//or
//List<Dictionary<string, decimal>> newgoodslist = new List<Dictionary<string, decimal>>();
newgoodslist.Add(new Dictionary<string, decimal>() {
{ "1", 258 },
{ "2", 152 }
});