Create an instance of a Generic Type and invoke C# with Example



Create an instance of a Generic Type and invoke C# with Example

it's method 
var baseType = typeof(List<>); 
var genericType = baseType.MakeGenericType(typeof(String)); 
var instance = Activator.CreateInstance(genericType); 
var method = genericType.GetMethod("GetHashCode"); 
var result = method.Invoke(instance, new object[] { }); 
 

0 Comment's

Comment Form

Submit Comment