.net 字典的速学

        private void Form1_Load(object sender, EventArgs e)
{
var myDict = new Dictionary<string, string>();
myDict.Add("1", "中国");
myDict.Add("2", "美国");
myDict.Add("3", "俄罗斯");
myDict.Add("4", "日本");

if (!myDict.ContainsKey("5"))
{
MessageBox.Show("5没有");
}

if (myDict.ContainsValue("中国"))
{
MessageBox.Show("有中国哦");
}
MessageBox.Show(myDict["4"]);

myDict["5"] = "新加坡";

if (myDict.ContainsKey("5"))
{
MessageBox.Show("现在有5了");
}

}

一眼理解系列~ 你懂?

原文地址:https://www.cnblogs.com/my36z/p/2288221.html