Pass type to generic method (nested generic)

后端 未结 2 1175
执笔经年
执笔经年 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: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).

提交回复
热议问题