1. Modifiers for classes in C #:
public means that access to the class is not restricted
protected means that access can only be made from subclasses that are derived from the class and the class in which they reside
private only the class in which it is located can access
internal only access to applications or libraries in a package
abstract class does not allow an instance of a class to be established
sealed sealed class is not allowed to be inherited
The definition of the protected modifier has changed compared to Java. The addition of internal in C # is similar to the definition of protected in Java. The sealed modifier is similar to the definition of final class in Java.
2. The This keyword in C # (similar to Java)
The reserved word this is limited to using the constructor class's methods and instances of the class to have the following meanings
1. This appears in the constructor of the class as a value type that represents a reference to the object being constructed
2. This occurs in the method of the class as a value type that represents a reference to the object that called the method
3. This occurs in the constructor of the struct as a variable type that represents a reference to the structure being constructed
4. This appears in the method of the struct as a variable type it represents a reference to the struct that called the method
In summary, this always represents a reference to the current object .
3. Static and non-static members in C #
If a member in a class is declared as static, the member is called a statics member. In general, static members are owned by the class, and non-static members belong to the instance of the class, which is all of the objects.
A non-static member of a class belongs to an instance of the class, and each instance that creates a class opens an area in memory for non-static members. A static member of a class is owned by the class and is shared by all instances of the class, regardless of how many copies the class creates, and a static member occupies only one area of memory.
C # Learning Note---modifiers, this keyword and the static keyword