Overloading & Overriding
To learn about Single & Double Dispatch, many design patterns, we need to understand Overloading and Overriding.
Overloading Overloading is compile-time polymorphism. The methods/functions with same name but different number/type parameters are example of Overloading.
As Overloading is compile-time, means during run-time the base type is considered. Example:
class Crop
{
public virtual void CropName()
{
Console.WriteLine("Hey, My type is Crop");
}
}
class Wheat : Crop
{
public override void CropName()
{
Console.WriteLine("Hey, My type is Wheat");
}
}
/* An example of overloading (Method with same name but different parameter type)
* */
class CropWatering
{
public void WaterSupply(Crop crop)
{
Console.