Virtual and override member function
class Class1
{
public virtual void Hello()
{
System.Console.Write( "Hello from Class1" );
}
}
class Class2 : Class1
{
public override void Hello()
{
base.Hello();
System.Console.Write( " and hello from Class2 too" );
}
public static void Main( string[] args )
{
Class2 c2 = new Class2();
c2.Hello();
}
}
Output Hello from Class1 and hello from Class2 too
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
-
-
|