Pass type to generic method (nested generic)

后端 未结 2 1167
执笔经年
执笔经年 2020-12-10 17:29

How can I invoke following method while I have not TRootEntity, but have just its TYPE:

public void Class(Action&l

相关标签:
2条回答
  • 2020-12-10 17:48

    Have a look at this answer from the great Jon Skeet. You should be able to adapt it to your needs.

    0 讨论(0)
  • 2020-12-10 17:59

    You cannot code Generic methods to run by passing a runtime Type.

    Generics need to have the type at compile time.

    You may need to use reflection (see answer of mr. Ferreira that point on how to do that).

    0 讨论(0)
提交回复
热议问题