adspace
Answer Posted / Deependra Verma
"To use Reflection to call a generic method, first obtain the Type object of the generic type, then create an instance of MethodInfo for the desired method using MakeGenericMethod(). Next, create an instance of the target type and call the method using Invoke(). Here is an example:nn```csharpnType genericType = typeof(List<>);nMethodInfo methodInfo = genericType.MakeGenericMethod(typeof(int));nobject obj = Activator.CreateInstance(genericType);nobject result = methodInfo.Invoke(obj, new object[] {});n``
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers