How to force overriding a method in a descendant, without having an abstract base class?

前端 未结 14 978
孤城傲影
孤城傲影 2020-12-09 07:24

Question Heading seems to be little confusing, But I will Try to clear my question here.

using System;
using System.Collections.Generic;
usi         


        
14条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 07:41

    A WA may be using an "Interface" so you define one like IBonusGiver { void GiveBonus(); } An then, instead of the abstract method and the overrides, you implement in all your classes this new interface. e.g. PTSalesPerson : SalesPerson, IBonusGiver forcing a new implementation in each class.

提交回复
热议问题