How to pass variable of type “Type” to generic parameter

后端 未结 2 1178
南笙
南笙 2021-02-14 08:43

I\'m trying to do this:

Type type = Type.GetType(string.Format(\"Gestor.Data.Entities.{0}, Gestor.Data\", e.Item.Value));
MetaDataUtil.GetColumnasGrid

        
2条回答
  •  不思量自难忘°
    2021-02-14 09:14

    You need to use reflection for this.

    var method =
        typeof(MetaDataUtil)
        .GetMethod("GetColumnasGrid")
        .MakeGenericMethod(new [] { type })
        .Invoke(null, null);
    

提交回复
热议问题