/*
* Created by sharpdevelop.
* User: noo
* Date: 2009-8-16
* Time: 20: 31
*
* Inheritance
*/
Using system;
Class
{
Public void output ()
{
Console. writeline ("a custom method 1 ");
}
Public Virtual void input ()
{
Console. writeline ("virtual function in ");
}
Public Void Do ()
{
Console. writeline ("a custom method 2 ");
}
}
Class B:
{
New public void output ()
{
Console. writeline ("hiding method 1 in B ");
}
Public override void input ()
{
Console. writeline ("B rewrite virtual functions ");
}
Public void dosomething ()
{
Console. writeline ("B custom method ");
}
}
Class Test
{
Static void main ()
{
// A = new A (); // call the method in
// A. Output ();
// A. Input ();
// A. Do ();
// A AA;
// B = new B ();
// AA = B;
A aa = new B ();
AA. Output (); // call the method in
AA. Input (); // call the method in B
AA. Do (); // call the common method in A and B
// B = new B (); // call the method in B
// B. Output ();
// B. Input ();
// B. Do ();
// B. dosomething ();
}
}
Running result