The difference between equals and = = difference between public variables and attributes summary _ Practical Tips

Source: Internet
Author: User
Tags reserved
The difference between Equals and = =
There are two different kinds of equality in C #: reference equality and value equality
= = is whether the value of two variables is the same or if two references are pointing to the same memory address.
The Equals () method compares the contents of two objects pointing to the memory space is not the same. That is to compare whether two reference types are references to the same object, that is, whether the contents of two objects are the same.

The difference between a public variable and a property

A variable is called a domain for the class itself.
An attribute is an externally displayed feature of a class, but exposes the property, how the assignment (set) and how to perform the value (get) are encapsulated, and are not visible to the outside of the class. For external users, it is only possible to use it, not to control it. How you control the operation is determined by the class itself.
Difference:
property is the encapsulation of a field
The data can be controlled by a read-write variable. (Set Get)
The data can be assigned and the variable is not available.
Data binding on an object, the data can be properly bound, the variable is not. When you need to set a value in a class to public, you should use a property instead of a variable.
The magical uses of the @ symbol
1: String escape character
"\" In C # Chinese special symbols, which represent escape characters, if the normal string "\" is required by \ \ Can, through the @ symbol, you can use the "\" as a common character.
String path= "F:\\vs2008\\1.txt";
String path=@ "F:\vs2008\1.txt"; This is the way to go.
2: Cross-line string with @
3: Reserved keyword identifiers in the C # specification, @ can act as the first character of the identifier (class name, variable name, method name) to allow the reserved keyword in C # as the identifier of its own definition.
such as public class @class


Recently changed a new company, feel good, there are a lot of things to learn, I feel the most difficult is the regular, will be the girl is very strong, in order to this sentence, to learn hehe.
The machine was out of shape yesterday. Take to repair, had to read, feel still good, these basic things, originally should have known, but yesterday just know, the foundation is not good, the foundation is not good, so to improve the things still a lot, JX refueling, still optimistic, optimistic down ...

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.