我有一些代码,我正在尝试反向进行For
循环,但似乎无法正常工作
Session("mysession") = "1234-5678-"
Dim delimiters As Char() = New Char() {"-"C}
Dim mystring As String() = Trim(Session("mysession")).Split(delimiters, StringSplitOptions.RemoveEmptyEntries)
For x = 0 to mystring.Length - 1
'Do Something
Next
这有效,但是以错误的顺序显示它我试图通过简单地执行此操作来反转它
For mystring.Length - 1 to x = 0
但我收到了错误
Expression is a value and therefore cannot be the target of an assignment.
有什么想法吗?
由于
答案 0 :(得分:3)
反向循环的语法不正确。它应该是:
For x = mystring.Length - 1 To 0 Step -1