C # Field property methods three Overlord Qi to battle

Source: Internet
Author: User
Tags modifiers

Chapter III:using Property PromotionMyBank

1. access modifiers :

Access modifiers

Access rights

Access level

Public

Not subject to any restrictions

Highest

Private

Only the inside of the class can be used

Minimum

2.this Keywords

The This keyword modifies the member variable .

3. The implementation of the fields and methods is combined by The Get and set accessors, which we call attributes .

4. shortcut key : ctrl+r+e: implement field Encapsulation . Example :

5. Benefits of Encapsulation :

1) Avoid using illegal data assignments .

2) ensure the integrity of the data .

3) to avoid changes within the class , resulting in the entire program modification .

6. value passing and reference passing :

1) before the parameter ref is the reference pass, he can use the method

The variables in the definition and method invocation are considered to be the same variable, so that they can be changed.

2) If there is no refbeforethe parameter, it is called the value Pass, and the value pass is discussed in the case:

If the parameter itself is a value type (int, double, float, char bool,), then two variables cannot be considered the same and, of course, the final value will not be modified.

If the parameter itself is a reference type (string, Array, custom class ), then two variables are

The same variable, of course, the final value will also be modified!

Do you have any gains today ? there must be. !!!! See you next time , Bye

C # Field property methods three Overlord Qi to battle

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.