C# - What should I do when every inherited class needs getter from base class, but setter only for O

Posted by msfanboy on Stack Overflow See other posts from Stack Overflow or by msfanboy
Published on 2010-06-03T11:20:34Z Indexed on 2010/06/03 11:34 UTC
Read the original article Hit count: 251

Filed under:
|
|
|
|

Hello,

I have a abstract class called WizardViewModelBase.

All my WizardXXXViewModel classes inherit from the base abstract class.

The base has a property with a getter. Every sub class needs and overrides that string

property as its the DisplayName of the ViewModel.

Only ONE ViewModel called WizardTimeTableWeekViewModel needs a setter because I have to set

wether the ViewModel is a timetable for week A or week B. Using 2 ViewModels like

WizardTimeTableWeekAViewModel and WizardTimeTableWeekBViewModel would be redundant.

I do not want to override the setter in all other classes as they do not need a setter.

Can I somehow tell the sub class it needs not to override the setter?

Or any other suggestion?

With interfaces I would be free to use getter or setter but having many empty setter

properties is not an option for me.

© Stack Overflow or respective owner

Related posts about c#

Related posts about class