Back to directory
PreviousArticleIt mainly shows you the Conversion Relationship between the base class and the derived class, that is, they cannot be converted to each other and can only be converted from the derived class to the base class, next we will look at an abstract class and a programming method implemented by its derived class, that is, abstract-oriented programming.
The following is an example of abstract-Oriented Programming: (complete)Code)
1 /// <Summary>
2 /// Base Class
3 /// </Summary>
4 Abstract Class Parent
5 {
6 Public String Name { Get ; Set ;}
7 }
8 /// <Summary>
9 /// Derived Class 1
10 /// </Summary>
11 Class Sub1: parent {}
12 /// <Summary>
13 /// Derived Class 2
14 /// </Summary>
15 Class Sub2: parent {}
16 Class Program
17 {
18 Static Void Main ( String [] ARGs)
19 {
20
21 Sub1 S1 = New Sub1 {name = " Sub1 class " ,};
22 Test (S1 );
23 Console. readkey ();
24 }
25 /// <Summary>
26 /// Abstract programming (class polymorphism)
27 /// </Summary>
28 /// <Param name = "entity"> </param>
29 Static Void Test (parent entity)
30 {
31 Console. writeline (entity. GetType ());
32 }
33 }
Back to directory