Override in C #. net)
Public Class Mybase
... {
Public Virtual String METH1 ()
... {
Return "MyBase-Meth1";
}
Public Virtual String Meth2 ()
... {
Return "MyBase-Meth2";
}
Public Virtual String Meth3 ()
... {
Return "MyBase-Meth3";
}
}
Class Myderived: mybase
... {
// Overrides the virtual method METH1 using the override Keyword:
Public Override String METH1 ()
... {
Return "MyDerived-Meth1";
}
// Explicitly hide the virtual method meth2 using the new
// Keyword:
Public New String Meth2 ()
... {
Return "MyDerived-Meth2";
}
// Because no keyword is specified in the following declaration
// A warning will be issued to alert the programmer that
// The method hides the inherited member mybase. meth3 ():
Public String Meth3 ()
... {
Return "MyDerived-Meth3";
}
Public Static Void Main ()
... {
Myderived MD= NewMyderived ();
Mybase MB=(Mybase) md;
System. Console. writeline (mb. METH1 ());
System. Console. writeline (mb. meth2 ());
System. Console. writeline (mb. meth3 ());
}
}