Articles → .NET DESIGN PATTERN → Liskov Substitution Principle In C#
Liskov Substitution Principle In C#
What Does Liskov Substitution Principle Say?
Example
public abstract class BaseClass {
public abstract string GetWelcomeMessage(string message);
}
public class ChildClass: BaseClass {
public override string GetWelcomeMessage(string message) {
return string.Format("Welcome {0}", message);
}
}
BaseClass baseClass = new ChildClass();
Console.WriteLine(baseClass.GetWelcomeMessage("Karan"));
Console.ReadLine();
Output
Click to Enlarge