Differences between Equals and =: differences between public variables and attributes ......

Source: Internet
Author: User

Equals and =

C # has two different types of equality: equal reference and equal value
= Compares whether the values of two variables are the same or whether the two references point to the same memory address.
The Equals () method compares whether the content of two objects pointing to the memory space is the same. That is, to compare whether two "reference types" are referenced to the same object, that is, whether the content of the two objects is the same.

Differences between public variables and attributes

 

A variable is called a field for a class.
Attributes are externally displayed features of the class. They are only public attributes. They are invisible to the outside of the class, such as how to encapsulate values (set) and how to encapsulate values (get. External users can only use it, but cannot control it. How to control operations is determined by the class itself.
Differences:
Attribute is encapsulation of fields
Attribute can control read/write variables. (Set get)
Attribute values can be assigned, but variables cannot.
When you bind data to an object, the data can be normally bound, and the variable won't work. When you need to set a value in the class to public, you should use attributes instead of variables.

@ Symbol

1: String Escape Character

"\" Is a special Chinese Character in c #. It represents an escape character. If it represents a common string "\", it must be \. Through the @ symbol, you can use "\" as a common character.

String path = "F :\\ vs2008 \ 1.txt ";
String path = @ "F: \ vs2008 \ 1.txt"; this is enough.
2: Use @ to represent a cross-line string
3: Keep the keyword identifier in the C # specification. @ can be the first character of the identifier (Class Name, variable name, method name, use the reserved keywords in c # as their own identifiers.
For example, public class @ class

Recently I changed to a new company. I feel pretty good. I have a lot to learn. I feel that the most difficult thing is regular expressions. The girl who will be regular expressions is very powerful. To answer this question, I should be eager to learn.

Yesterday, when the machine went out of service, I had to read the book. I felt good. These basic things should have been known for a long time, but I only learned yesterday that the Foundation is not good and the foundation is not good, so there are still a lot of things to be improved, and JX is always optimistic and optimistic ......

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.