In C #, why we don't have a compilation error even if we forget the keyword "Virtual" in a method of a base class, redefined in a derived class.
I learnded that this keyword is mandatory to override a method
is not it ?
public class Mother
{
public void Speak()
{
Console.WriteLine("Mother !");
}
}
public class Son : Mother
{
public void Speak()
{
Console.WriteLine("Son!!");
}
}
Should be :
public class Mother
{
public virtual void Speak()
{
Console.WriteLine("Mother !");
}
}
public class Son : Mother
{
public override void Speak()
{
Console.WriteLine("Son!!");
}
}