ASP. NET learning notes (10) Equals and operators =

Source: Internet
Author: User

= Is used to compare whether the values are equal. Equals is used to compare equal references. This means that not two objects are compared, but two objects are referenced, and the references of two objects are referenced by the same object.
1. Value Type
Equal value, equal

II. For reference types
1. = compare whether the values of the two variables are equal, or whether the two references point to the same memory address

2. equals checks whether the content of the two objects points to the same memory space;

For the reference type, = is similar to comparing whether the folder path is the same, while the equals method compares whether the content in the folder is the same


= Determines the value type. If the value is equal, the value is true. The same applies to equals.


Instead of allocating memory to s2, the system points "test" to s2, which is called memory optimization.


S3 and s4 are value types


O3 and o4 are reference types. If the address stored in the memory is different, = false
The content stored in the memory space is the same, so equals is true.

 

Is a different object, and the content is different, so it is false.


References the same object.

By: dxh_0829
 

Related Article

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.