====== 実行結果 ======
$ dotnet run
This is VirtualMethodSample(Child Class).
====== ソース ======
using System;
namespace console
{
class Program
{
static void Main(string[] args)
{
VirtualSuperClass VirtualSample = new VirtualChildClass();
VirtualSample.VirtualMethodSample();
}
}
public class VirtualSuperClass
{
public virtual void VirtualMethodSample()
{
Console.WriteLine("This is VirtualMethodSample(Super Class).");
}
}
public class VirtualChildClass : VirtualSuperClass
{
public override void VirtualMethodSample()
{
Console.WriteLine("This is VirtualMethodSample(Child Class).");
}
}
}