在此vb.net函数的代码片段中,在A点或B点声明变量是否更有效?
我意识到可以在不声明x和y的情况下进行编程:返回x + GetY()+ GetZ(),但这不是我要的答案。
Private Function Sum(ByVal x As Integer)
Dim y As Integer ' A) declare variables here?
Dim z As Integer
If x <> 0 Then
'Dim y As Integer 'B) or declare variables here?
'Dim z As Integer
y = GetY()
z = GetZ()
Return x + y + z
Else Return x
End If
End Function