vb.net - 在 Visual BASIC .net 中声明变量是否会影响效率?
问题描述
在这个 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
解决方案
推荐阅读
- python - 在python中并行运行2个不同的程序
- java - 我想捕捉弹出消息并获取其文本内容
- awk - awk 选择带有变量的行,无法打开没有这样的文件
- java - USB 通讯错误 - Android 开发
- wordpress - 使用 WPML 和 Woocommerce Rest API 以第二语言创建产品
- java - Cassandra InvalidQueryException:键可能不为空
- firebase - Flutter - 如何使用 Firebase 实时数据库中的时间戳对检索到的列表进行排序
- swift5 - TableView Getter 的 Swift 5.3 编译器崩溃
- javascript - 如何将javascript中的日期格式化为DD-MMM-YYYY?
- python - 如何在 Python 中创建一个简单的 HTTPS 服务器?