Question:Which of the following code snippets will call a generic method when the type parameter is not known at compile time? 

A var name = InvokeMemberName.Create; Impromptu.InvokeMemberAction(this, name("GenericMethod", new[]{myType})); 

B MethodInfo method = typeof(Sample).GetMethod("GenericMethod"); MethodInfo generic = method.MakeGenericMethod(myType); generic.Invoke(this, null); 

C Action<> GenMethod = GenericMethod< myType >; MethodInfo method = this.GetType().GetMethod(GenMethod.Method.Name); MethodInfo generic = method.MakeGenericMethod(myType); generic.Invoke(this, null); 

D Action<> GenMethod = GenericMethod< myType >; MethodInfo method = this.GetType().GetMethod("GenericMethod"); MethodInfo generic = method.MakeGenericMethod(myType); generic.Invoke(this, null); 

+ Answer
+ Report
Total Preview: 1086

Copyright © 2024. Powered by Intellect Software Ltd