您的位置:首页 > 编程语言 > C#

C# Dictionary的使用实例代码

2013-04-08 16:05 811 查看

            Dictionary<int, string>.ValueCollection collection = productList.Values;            foreach (var item in collection)            {                MessageBox.Show(string.Format("{0}", item));            }            //productList.Remove(1);            //productList.Clear();            MessageBox.Show("判断是否包含键值对中的键为”1“的值");            if (productList.ContainsKey(1))            {                MessageBox.Show(productList[1]);            }            MessageBox.Show("判断是否包含键值对中的值为”ProductionTwo“的值");            if (productList.ContainsValue("ProductionTwo"))            {                MessageBox.Show(string.Format("{0}", "this really exists"));            }        }

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Dictionary 使用