I have googled couple of times but still can\'t understand the supertype method. Can anyone please explain what is this?
Super Type and sub type is a property of inheritance i.e for the purpose of re-usability of code. I am giving you example of Super Class and Sub class. For more you can follow here.
using System;
namespace MultilevelInheritance
{
public class Customer
{
public float fDis { get; set; }
public Customer()
{
Console.WriteLine("I am a normal customer.");
}
public virtual void discount()
{
fDis = 0.3F;
Console.WriteLine("Discount is :{0}", fDis);
}
}
public class SilverCustomer : Customer
{
public SilverCustomer()
: base()
{
Console.WriteLine("I am silver customer.");
}
public override void discount()
{
fDis = 0.4F;
Console.WriteLine("Discount is :{0}", fDis);
}
}
class GoldenCustomer : SilverCustomer
{
public GoldenCustomer()
{
Console.WriteLine("I am Golden customer.");
}
public override void discount()
{
fDis = 0.6F;
Console.WriteLine("Discount is :{0}", fDis);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MultilevelInheritance
{
class Program
{
static void Main(string[] args)
{
Customer objCus = new Customer();
objCus.discount();
SilverCustomer objSil = new SilverCustomer();
objSil.discount();
GoldenCustomer objGold = new GoldenCustomer();
objGold.discount();
Console.ReadLine();
}
}
}
enter image description here