Optimizing the performance of vb.net applications (1)

Source: Internet
Author: User
Tags integer integer division
Program | performance | Optimization 1 integer division operators \ and/
\ faster than/10 times times (if it is integer division and does not need to keep decimals)

(2) Assignment operator a +=b and a = A+b
= Fast

(3) Series Operators & and +
Use & Quick

(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 did not need decimal points or fractional values. The \ operator is the integral division operator and it are up to the faster than the/(forward slash) operator.

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

Compound assignment Statements-perform-a operation on a argument before assigning it to another. Example:

A + b

In the example above, B are added to the value of a, and that's new value is then assigned to a. Compound assignment s 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 are operating on a expression instead of a single variable, for example an array element, can achieve a signif Icant improvement with compound assignment operators.

Compound assignment operators for numbers:

^=
*=
/=
\=
+=
-=
Compound operator for strings: &= Example:

Dim A as String = "The" a &= "Name"
Result:first Name

Concatenation: & V.s. +

Use the & concatenation operator instead of the + operator to increase the speed of concatenations. Performance of the & and + operators are only equivalent if both operands type String. If not, the + operator is late bound and must perform type checking and conversions.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.