Control accessibility:
Private a method or field is only allowed to be accessed from within the class, and the Private keyword is the default
Public methods or fields can be accessed from within and outside of the class
The variables declared in the method are not initialized by default, and the fields in the class are automatically initialized to 0,null,false
Using the constructor:
Has the same name as the class. Can get the parameter, but cannot return any value (even void), the constructor is generally declared public, and if declared as private, the object of the externally constructed class can no longer be class.
Partial class:
Class is decorated with the partial keyword.
If the parameter in the method has the same name as a variable, the parameter overrides the field in any statement of the method, and the field is applied with the This keyword before the field.
Understanding static methods and data:
If you declare a method or field as static, you can call a method or field with the class name, in a static static method, you cannot access any instance fields defined in the class, you can only access the static field, and you can call only the other static methods in the class. A non-static method must first create an instance before the methods can be called on the object.
To create a shared field:
When a field is defined as static, you can create a field that can be shared among all objects of the class. Modifying a static field will work for all objects. Call a static field to make a call using the class title as a prefix.
To create a static field using the Const keyword:
The value of a field that is decorated with the Const keyword never changes, and its decorated field can only be an enumeration, a numeric type, or a string.
Static class:
The static keyword is used in the class's modifier, which can only contain static members, static classes cannot contain any instance data and methods, and the static fields and methods cannot append the This keyword as a prefix.
Anonymous class:
Anonymous classes can contain only public fields, fields must all be initialized, cannot be static fields, and no methods can be specified in them. The format is: Var a=new {name= "mountains", age=11};
C # Basic Grammar review-Create and manage classes and objects