How to handle a class you want to extend which is sealed in the .NET library?

前端 未结 7 1390
礼貌的吻别
礼貌的吻别 2021-01-02 02:54

I was reading somewhere about how to handle the issue of wanting to extend a sealed class in the .NET Framework library.

This is often a common and useful task to do

7条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 03:31

    Extension methods is one way, the alternative being the Adapter Pattern. Whereby you write a class that delegates some calls to the sealed one you want to extend, and adds others. It also means that you can adapt the interface completely into something that your app would find more appropriate.

提交回复
热议问题