VB.Net更快地对数组中的值求和的方法

时间:2016-05-20 16:05:01

标签: arrays vb.net

目前我使用for循环来对存储在字节数组类型中的值进行求和:

Dim values As Byte() = {1, 23, 42, 12, 9, 102, 86, 0, 0, 0, 0, etc...}
Dim sum As Integer
For Each value As Byte In values
     If value = 0 Then
          Exit For
     End If
     sum += value
Next

由于这是每秒多次调用的函数的一部分,是否有更快/更有效的方法来对存储在数组中的值求和?

0 个答案:

没有答案