using System.Collections;
IDictionary<string, int> dic = new Dictionary<string, int>();//创建对象 string(object) 是key int(object) 是值
dic.Add("key1", 0);
dic.Add("key2", 1);
dic.Add("key3", 1);
if (dic.ContainsKey("key1"))
{
dic.Remove("key1");
}
foreach (string key in dic.Keys)
{
Console.WriteLine(string.Format("这个Key:{0}, 值:{1}。", key, dic[key]));
}
IDictionary 泛型集合的应用
最新推荐文章于 2024-07-06 19:49:00 发布