Optimize the performance of VB.NET applications (1)

zhaozj2021-02-16  104

(1) Integer division operators / and / /

/ Radi / fast 10 times (if it is an integer division and does not need to keep a decimal)

(2) Assignment operator A = B and A = A B

= Fast

(3) Series operators &

Use & fast

(source:

http://www.devcity.net/newsletter/archive/devcity/devcity20040315.htm#ni030)

.NET PRO:

Optimize the Performance of VB.NET Applications

Operators

By Mike McINTyre

Division: / v.s. /

Divide integral values ​​with the / (back slash) operator when you do not need decimal points or fractional values. The / operator is the integral division operator and it is up to 10 times faster than the / (forward slash) operator.

Compound Assignment Operators: a = b v.s a = a b

Compound Assignment Statements First Perform An Operation ON AN Argument Before Assigning It To Another Argument. EXAMPLE:

A = B

In the example above, b is added to the value of a, and that new value is then assigned to a. Compound assignment operators are more concise than their constituent operators (separate and =). Compare the statement above to the one below. The Statement Above Is A Shorthand Equivalent of The Statement Below.

A = a b

Compound assignment operators are faster. If you are operating on an expression instead of a single variable, for example an array element, you can achieve a significant improvement with compound assignment operators.

Compound Assignment Operators for NumBers:

^ = * = / = / = = - =

Compound Operator for strings: & = esample:

Dim a as string = "first" a & = "name"

Result: First Name

Concatenation: & v.s.

转载请注明原文地址:https://www.9cbs.com/read-13400.html

New Post(0)