No, there is no equivalent of the out
keyword in VB.
However, VB does automatically initialise all local variables in a method, so you can use ByRef
without needing to explicitly initialise the variable first.
Example:
Sub Main()
Dim y As Integer
Test(y)
End Sub
Sub Test(ByRef x As Integer)
x = 42
End Sub
(If you examine code in the framework (for example Double.TryParse), you may see the <OutAttribute>
added to parameters, but that only makes a difference when the call is marshalled for COM interop or platform invoke.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…