Differences between reference and value types in as 3.0

Source: Internet
Author: User

The previous section describes the differences between as 3.0 references and value types. References are often used in programming and are useful, at least what are the advantages? You can think about it yourself. I will not mention it. Now, let's compare the difference between reference and value type.

Value type:

Is to directly access the variable address

Reference:

Is to reference the address of a variable, the value will change because of a variable change

Here is an example.

Var an: int = 3;

Var bn: int =;

Bn = 65555;

Trace (The 'an value is '+ );

Trace (The 'an value is '+ bn );

The output value is:

An = 3; bn = 65555;

This is a feature of the value type. Let's look at the reference below.

Var td: array = new array (1, 2 );

Var bd: array = td;

Bd [0] = 120;

Trace (The 'an value is '+ td );

Trace (The 'an value is '+ bd );

The output values of td and bd are:, 2, 1

Well, if you can understand it, you have to take a look. Finally, I would like to make a statement. Please respect my work. Please refer to www.111cn.net/flash_a/flash.html.

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.