New class, New completes two things: one is to call the new Class command to allocate memory for the instance in the managed heap, and the other is to call the constructor to implement the object initialization.
Shows hidden members that inherit from the base class. Although you can hide members without the new modifier, a warning is generated. If a hidden member is displayed with the New keyword, this warning is canceled.
no new keyword code:
There is a new keyword code:
Results:
Note:
A method defined in a subclass with the same name as the parent class in the New keyword adornment is called overwrite. Overwriting does not change the functionality of the parent class method.
When a subclass creates a parent class, a c = new B () in the code overrides does not change the functionality of the parent class. The functionality of the parent class is still called.
The new constraint means that any parameter type in a generic class declaration has a parameterless constructor, and when used with other constraints, the new constraint must be specified last.
Public class where class,new() { }
C # Basic knowledge of the New keyword