当前位置:编程学习 > C#/ASP.NET >>

Dictionary通过下标获取key和value

 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;
                }
            }

 

补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,