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


Picture showing the output of Liskov substitution principle in C#
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, December 28, 2020

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250