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

前端 未结 13 2193
没有蜡笔的小新
没有蜡笔的小新 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:21

    You'd have to do something like:

    For i as integer = myStringList.Count-1 to 0 step -1
        dim s as string = myStringList.Item(i)
        ' Do your stuff with s
    Next i
    

    But as far as I know, you can't do a "For...Each" backwards, though that would be nice in a few instances.

提交回复
热议问题