Instructing a generic to return an object of a dynamic type

前端 未结 2 687
暗喜
暗喜 2021-01-28 18:48

This question is sort of a follow-up to my original question here.

Let\'s say that I have the following generic class (simplifying! ^_^):

class CasterCla         


        
2条回答
  •  野性不改
    2021-01-28 18:56

    If you have control over the classes you'll be working with, have them all instantiate an interface that contains the methods you'll be calling and once you instantiate, cast to the interface.

    I also posted an answer to your previous question with the same idea.

提交回复
热议问题