Overriding
From this example, the field named type is using overriding.Override field

Override method

virtual and override keyword
Reference to the example above, the variable student2 and teacher2, this load base class method because it overrides the derived class method, when they share the same name.However, C# provides an option to override the base class method, by adding the virtual keyword to the method inside the base class, and by using the override keyword for each derived class methods:

No comments :
Post a Comment