Dictionary字典集合的使用

Dictionary<string, string> dic = new Dictionary<string, string>();

            foreach (DataRow r in dt.Rows)
            {
                string str = Convert.ToString(r["strLogisticsType"]);
                if (dic.ContainsKey(str))
                {
                    continue;
                }
                dic.Add(str,str);
            }
            KeyValuePair<string, string> keyPair;

            Dictionary<string, string>.Enumerator dicR = dic.GetEnumerator();
            while (dicR.MoveNext())
            {
                keyPair = dicR.Current;
                _Logistics.Text += keyPair.Key + " ";
            }

posted on 2011-09-29 14:34  上校  阅读(282)  评论(0编辑  收藏  举报