Dictionary<int, string> dic = new Dictionary<int, string>();
//添加元素
dic.Add(1, "小棠");
dic.Add(2, "小吴");
//判断某个key是否存在
if (!dic.ContainsKey(2))
{
dic.Add(2, "小吴");
}
//移除某个
dic.Remove(3);
//获取某个的值
string a = dic[2];
//遍历数据
foreach (KeyValuePair<int, string> kvp in dic)
{
Response.Write(kvp.Key + "," + kvp.Value);
}
//遍历key
foreach (int s in dic.Keys)
{
}
//遍历value
foreach (string s in dic.Values)
{
}