C#: Method to return object whose concrete type is determined at runtime?

前端 未结 4 1438
失恋的感觉
失恋的感觉 2021-02-10 07:25

I\'m thinking about designing a method that would return an object that implements an interface but whose concrete type won\'t be know until run-time. For example suppose:

4条回答
  •  执笔经年
    2021-02-10 07:36

    You would want just a virtual method, SpecificationMethod, which is implemented in each class. I recommend reading FAQ Lite's content on inheritence. The design method's he mentions can be applied to .Net as well.

提交回复
热议问题