这是我的基本问题:如果我循环浏览我以特定方式排序的字典,在循环中的任何给定点内如何“窥视”或引用字典项“x”位于当前位置之前项目而不更改当前的枚举器?例如:
Dim tempDictionary = New Dictionary(Of String,String)tempDictionary.Add("Testname1","TestValue1")tempDictionary.Add("Testname2","TestValue2")tempDictionary.Add("Testname3","TestValue3")'... and so on ... 'For Each Item In tempDictionary DoStuff(Item) 'Here is the point in which I want to see what the value of the' 'dictionary item that is 1,2,3,[x] places in front of the current' 'item without interfering w/ the current loop.' 'CODE'Next
提前致谢!
解决方法 声音就像你想要一个c风格的循环.在这里原谅C#(因为你在VB中问过)for (int i = 0; i < myArray.Length; i++) { object current = myArray[i]; if(i + 1 < myArray.Length) { // make sure there is a next item object nextItem = myArray[i + 1] }}
如上所述,字典不是有序的,但您可以将Keys放在一个数组中以使用上面的内容.
总结以上是内存溢出为你收集整理的.net – 循环字典项目时“偷看”全部内容,希望文章能够帮你解决.net – 循环字典项目时“偷看”所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)