"has-a"
"has-a" Relationship in C# The "has-a" relationship in object-oriented programming (OOP) refers to composition, where one class contains an instance of another class as a member. This contrasts with the "is-a" relationship, which involves inheritance. In C#, the "has-a" relationship is implemented through composition, allowing a class to include an object from another class as part of its state. This provides more flexible designs, enabling interaction between objects without requiring one class to be a specialized version of another. Example of "has-a" Relationship Let's look at an example where a Car class has an Engine . The Car does not "is-a" Engine, but it "has-a" Engine because a car contains an engine to function. public class Engine { public void Start() { Console.WriteLine("Engine starting..."); } public void Stop() ...