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