Is it possible to do a For…Each Loop Backwards?

前端 未结 13 2167
没有蜡笔的小新
没有蜡笔的小新 2020-12-06 03:53

I don\'t believe this is possible by conventional methods, but something like this verbose code:

For Each s As String In myStringList Step -1
    //\' Do stu         


        
相关标签:
13条回答
  • 2020-12-06 04:47

    The accepted answer explains why, but to add another example, for a collection with key (SortedList, SortedDictionary, Dictionary, etc.) you can do

    For Each Id as Tkey in MyCollection.Keys.Reverse
       // The item in question is now available as MyCollection(Id)
    Next
    
    0 讨论(0)
提交回复
热议问题