C # constructor,
Constructor is a special member function. It is mainly used to allocate storage space for objects and initialize data members.
Constructor has some special properties:
(1) The name of the constructor must be the same as that of the class;
(2) The constructor does not return a type. It can contain parameters or not;
(3) When declaring a class object, the system automatically calls the constructor. The constructor cannot be explicitly called;
(4) constructors can be overloaded to provide different methods for initializing class objects;
(5) If no constructor is defined during declaration, the system automatically generates the default constructor. The constructor body is empty.
(6) static constructor. static modifier is used to initialize static variables. A class only allows one constructor to be loaded during class instantiation. The modifiers public and private are ineffective.
(7) public, protected, and private modifiers can be used ..
(8) use the (): base () method when referencing the parent class constructor. Use (): this (int para) to reference its own overloaded constructor ).
(7) public, protected, and private modifiers can be used.