Sure.
Instead of inheriting from a base class and method overriding like here:
public class MyClass:BaseClass { public override void Foo() { base.Foo(); } }
You add the class variable of a given class and calls it's method if needed.
public class MyClass { private BaseClass _baseClass = new BaseClass(); public void Foo() { _baseClass.Foo(); } }
More about the comparison between Inheritance and Composition you can find here. Take a closer look at the table at the end of article.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Sure.
Instead of inheriting from a base class and method overriding like here:
You add the class variable of a given class and calls it's method if needed.
More about the comparison between Inheritance and Composition you can find here. Take a closer look at the table at the end of article.