C\#Dictionary 의 몇 가지 옮 겨 다 니 는 방법

블 로그http://www.cnblogs.com/cjdxhc_site/articles/1727763.html
Dictionary<string, int> list = new Dictionary<string, int>();
 
            list.Add("d", 1);
 
            //3.0    
            foreach (var item in list)
            {
                Console.WriteLine(item.Key + item.Value);
            }
            //KeyValuePair<T,K>
            foreach (KeyValuePair<string, int> kv in list)
            {
                Console.WriteLine(kv.Key + kv.Value);
            }
            //       
            foreach (string key in list.Keys)
            {
                Console.WriteLine(key + list[key]);
            }
            //    
            foreach (int val in list.Values)
            {
                Console.WriteLine(val);
            } 
            //    for     
            List<string> test = new List<string>(list.Keys);
 
            for (int i = 0; i < list.Count; i++)
            {
                Console.WriteLine(test[i] + list[test[i]]);
            }

좋은 웹페이지 즐겨찾기