lundi 18 juillet 2016

How to get generic type from generic definition and generic arguments?

In C#, how can I construct generic type from generic definition and generic arguments like

var genericDefinition = typeof(List);
var genericArgument = typeof(string);
// How can I get the Type instance representing List<string> from the 2 variables above?

In my usecase, the generic argument is dynamically resolved. Is this possible in C#? Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire