亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C# Dictionary的使用實(shí)例代碼

 更新時(shí)間:2013年04月08日 16:05:29   作者:  
C# Dictionary的使用實(shí)例代碼,需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

class Dirctonary
    {
        public void DictionaryGet()
        {
            Dictionary<int, string> productList = new System.Collections.Generic.Dictionary<int, string>();
            productList.Add(1, "ProductionOne");
            productList.Add(2, "ProductionTwo");

            foreach (KeyValuePair<int, string> production in productList)
            {
                MessageBox.Show(string.Format("{0},{1}", production.Key, production.Value));
            }
            //MessageBox.Show(productList.Count.ToString());
            //MessageBox.Show(productList[1].ToString());
            Dictionary<int, string>.KeyCollection keys = productList.Keys;
            foreach (var item in keys)
            {
                MessageBox.Show(item.ToString());
            }

            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("判斷是否包含鍵值對(duì)中的鍵為”1“的值");
            if (productList.ContainsKey(1))
            {
                MessageBox.Show(productList[1]);
            }
            MessageBox.Show("判斷是否包含鍵值對(duì)中的值為”P(pán)roductionTwo“的值");
            if (productList.ContainsValue("ProductionTwo"))
            {
                MessageBox.Show(string.Format("{0}", "this really exists"));
            }
        }

相關(guān)文章

最新評(píng)論