programming:メソッドのオーバライド
実行結果
$ dotnet run This is VirtualMethodSample(Child Class).
ソース
- Program.cs
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)."); } } }
programming/メソッドのオーバライド.txt · 最終更新: 2017/08/09 05:37 by dot