1. Call the cognominal method in the base class
[Csharp]
Public class Person
{
Protected string ssn = "444-55-6666 ";
Protected string name = "John L. Malgraine ";
Public virtual void GetInfo ()
{
Console. WriteLine ("Name: {0}", name );
Console. WriteLine ("SSN: {0}", ssn );
}
}
Class Employee: Person
{
Public string id = "ABC567EFG ";
Public override void GetInfo ()
{
// Calling the base class GetInfo method:
Base. GetInfo ();
Console. WriteLine ("Employee ID: {0}", id );
}
}
Class TestClass
{
Static void Main ()
{
Employee E = new Employee ();
E. GetInfo ();
}
}
/*
Output
Name: John L. Malgraine
SSN: 444-55-6666
Employee ID: ABC567EFG
*/
2. Call the construction method of the base class
[Csharp]
Ublic class ActionCancelEventArgs: System. ComponentModel. CancelEventArgs
{
Public ActionCancelEventArgs (): this (false ){}
Public ActionCancelEventArgs (bool cancel): this (false, String. Empty ){}
Public ActionCancelEventArgs (bool cancel, string message): base (cancel)
{
This. message = message;
}
Public string Message {get; set ;}
}
Author: luolunz