Dictionary and value by acquiring key index

 Dictionary<int, string> dic = new Dictionary<int, string>();
            Dictionary<int, string>.Enumerator en = dic.GetEnumerator();
            for (int i = 0; i < dic.Count; i++)
            {
                if (en.MoveNext())
                {
                    int key = en.Current.Key;
                    string value = en.Current.Value;
                }
            }

 

Guess you like

Origin www.cnblogs.com/yinmu/p/11757861.html