我正在看vb.net中的這種方法,我很清楚vb.net。我想了解爲什麼在方括號中定義整數「[to]」和「[step]」?有人可以向我解釋這一點。爲什麼只能將這些定義爲/步驟。我附上了下面的代碼。提前致謝。在VB.net的方括號內的方法上定義變量有什麼用?
''' <summary>
''' Write to runtime output with loop information
''' Expected use when loop counter is incremented
''' </summary>
Public Sub WriteToRuntimeOutput(counter As Integer, [to] As Integer, [step] As Integer)
Dim message As New StringBuilder
message.AppendFormat("Loop counter incremented. Loop {0}/{1}", counter, [to])
If loopStep <> 1 Then
message.AppendFormat(" Step {0}", [step])
End If
message.Append(".")
return message.ToString()
End Sub
可能重複[在VB.NET標識符周圍的方括號是什麼意思?](http://stackoverflow.com/questions/6413343/what-do-square-brackets-around-an-identifier-in- vb-net-signify) –
嗨托馬斯,謝謝指出。在發佈我的問題之前,我確實看過了這個問題。上面的問題回答了一個枚舉。我知道如果一個方括號用於枚舉,但我的問題是爲什麼一個整數的方括號,爲什麼不把「[to]」定義爲計數器變量。我在上面的問題中提出了這個問題,非常感謝您的建議。 – Nisha