.Net class inheritance

Quick demo to show class inheritance:


using System;

namespace ConstructorTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var tester = new C();
            Console.ReadKey();
        }
    }

    public class A
    {
        public A(string input)
        {
            Console.WriteLine("From A " + input);
        }
    }

    public class B : A
    {
        public B(string input)
            : base("From B")
        {
            Console.WriteLine("From B " + input);
        }
    }

    public class C : B
    {
        public C()
            : base("From C")
        {
            Console.WriteLine("From C");
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *