Is there a built-in way to multiply every member of an array by some number in-place?
Example:
Dim volts () as Double = {1.243, 0.534, 5.343, 2.223, 4.334}
Dim millivolts (4) as Double = volts.MultiplyEachBy(1000) 'something like this
You can use the Array.ConvertAll
method.
Array.ConvertAll(volts, Function(x) x * 1000)
EDIT
There is a small error in the sample code which needs to be corrected for the above to compile. Remove the explicit size (4) from the variable type
Dim volts() As Double = {1.243, 0.534, 5.343, 2.223, 4.334}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With