user5841191
user5841191

Reputation:

private non-abstract members in an abstract class and inheritance C#

Is it a good practice to have private non-abstract methods in a abstract class ?

I want to use this non-abstract methods to do some internal operations in the base class.

Upvotes: 2

Views: 820

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 727047

Private methods are OK everywhere, because they are, well, private, which makes them invisible to anyone using the classes that you design. Private members come with no future obligations on your part: if you don't like them, you can change them at any time.

Abstract classes let you share implementation among classes inheriting from them. It is entirely up to you to decide what implementation you wish to share, and what language features you are going to use for the implementation of these shared features. This includes private methods, private variables, private nested classes, and so on.

Upvotes: 3

Related Questions