【C#学习笔记】Dictionary容器使用

2021-09-10 09:12

阅读:1007

标签:move   cat   使用   hang   int   gen   学习笔记   ring   oid    using System; using System.Collections.Generic; namespace ConsoleApplication { class Program { static void Main(string[] args) { Dictionary a = new Dictionary(); a.Add("xiaoming", 10); a["xiaozhang"] = 11; a.Add("xiaoli", 12); foreach (KeyValuePair i in a) { Console.Write(i.Key + ":" + i.Value); Console.WriteLine(); } Console.WriteLine(); a.Remove("xiaoming"); foreach (KeyValuePair i in a) { Console.Write(i.Key + ":" + i.Value); Console.WriteLine(); } a.ContainsKey("xiaoli"); //返回bool a.ContainsValue(11); //返回bool int s = a["xiaozhang"]; Console.Write(s); Console.Read(); } } }  【C#学习笔记】Dictionary容器使用标签:move   cat   使用   hang   int   gen   学习笔记   ring   oid   原文地址:http://www.cnblogs.com/tiandsp/p/7440415.html


评论


亲,登录后才可以留言!