C#Dictionary 实例

时间:2022-02-22 09:04:32
 Dictionary<int, string> dc = new Dictionary<int, string>();
dc.Add(, "看了");
dc.Add(, "没看");
dc.Add(, "不知道"); dc[] = "哈哈"; foreach (KeyValuePair<int,string> item in dc)
{
Console.WriteLine("{0}---{1}", item.Key, item.Value);
} //foreach (var item in dc.Keys)
//{
// Console.WriteLine("{0}---{1}", item, dc[item]);
//} Console.ReadKey();