====== 実行結果 ======
$ dotnet run
This is SuperClassSample Constructor.Argument is 1234
This is ChildClassSample Constructor.
====== ソース ======
using System;
namespace console
{
class Program
{
static void Main(string[] args)
{
ChildClassSample Child = new ChildClassSample();
}
}
public class SuperClassSample
{
public SuperClassSample(int IntArg)
{
Console.WriteLine("This is SuperClassSample Constructor.Argument is " + IntArg);
}
}
public class ChildClassSample : SuperClassSample
{
// we need "base(some integer variable)" because compiler can not know how to call SuperClass Constructor.
public ChildClassSample() : base(1234)
{
Console.WriteLine("This is ChildClassSample Constructor.");
}
}
}