Суббота, Май 30, 2020

Constructor

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Constructor
{
    class MyBaseClass
    {
        public MyBaseClass(string baseClassNeedsThis)
        {
            Console.WriteLine("This is the base class: "+baseClassNeedsThis);
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Constructor
{
    class MySubClass : MyBaseClass
    {
        public MySubClass(string baseClassNeedsThis,
            int anotherValue):base(baseClassNeedsThis)
        {
            Console.WriteLine("This is the subclass: "+baseClassNeedsThis
                +" and " + anotherValue);
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Constructor
{
    class Program
    {
        static void Main(string[] args)
        {
            MySubClass mysubClass = new MySubClass("call", 1);
            Console.ReadLine();
        }
    }
}
Back to Top