Structs and classes are tied and are templates that create objects
modifier struct struct name
1, struct is a value type, class is a reference type
2, the structure can not contain explicit parameterless constructors, struct members will automatically initialize the default value, can not be declared when the assignment is initialized
3. Cannot have base class (cannot base) does not support inheritance
4. After declaring the struct type, you can use the new operator to create the constructed object, or you can not use new. If new is not applied, the field remains unassigned and the object is not available until all fields are initialized
Object-oriented four features:
Encapsulation: Does not destroy the original data, equivalent to the data extracted in the corresponding class for processing execution
Inheritance: By: Implementing
Abstract:?
Polymorphism: Implemented by the virtual override method Note: The base class is not virtual (Vsan), the new class is the equivalent of hidden and the override has only one method of this. Fun ();
Re-new a method with the same name can be used with two methods; one is Base.fun (); Fun ();
About interfaces
1. Can be composed of any combination of methods, properties, events, indexers , cannot contain constants (const), fields, operators, instance constructors, destructors, types
Also cannot contain static members of any kind. the interface member must be public.
2, C # does not support the direct multi-inheritance, but can be implemented through the interface multiple inheritance, the interface can also inherit, ordinary classes and abstract classes can inherit from the interface. A class can inherit a class and multiple interfaces at the same time, but the interface cannot inherit the class
About abstract
1, used to describe the generality, regardless of the specific implementation, only determine the behavior must have (that is, to determine the abstract method)
2. Classes that contain abstract methods are abstract classes
The abstract method of implementing a base class in a derived class is to override the base class method using override
About interfaces, classes, and abstractions
An abstract class is an incomplete class that needs to be refined by a derived class
An interface is just a constraint on a class, only a method that a class can invoke is promised
A class can implement several interfaces at a time, but a class may inherit only one base class
An abstract class simply implements its abstract method by a derived class, and the interface requires that all its members be implemented
In practical programming, interfaces are used much more widely than abstract classes.
About Seal class
Can not be used as a class of the base class, thus ensuring that the sealing class of sealing and security (sealed implementation) the actual use of very little, simply to ensure the safety of
Object-oriented understanding of essays