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

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

    first you should create a list(of string) in for each statement, and after that make another normal for .. step -1 ..next statement. see an example:

    Dim ff As New List(Of Integer)
    For Each rRow As DataRow In DeletedRows
    Dim item As Integer
    item = rRow.Table.Rows.IndexOf(rRow)
    ff.Add(item)
    Next
    For i As Integer = ff.Count - 1 To 0 Step -1
    dim item as integer=ff(i)
    next i
    

    i hope that be helpful

提交回复
热议问题