IMethodInfo methodInfo = typeof(MyClass).GetMethod("MyMethod"); string methodName = methodInfo.Name; Console.WriteLine("Method name: " + methodName);
IMethodInfo methodInfo = typeof(MyClass).GetMethod("MyMethod"); foreach (var parameterInfo in methodInfo.GetParameters()) { Console.WriteLine("Parameter name: " + parameterInfo.Name); Console.WriteLine("Parameter type: " + parameterInfo.ParameterType); }In this example, we retrieve an instance of IMethodInfo for a method named "MyMethod" in a class called MyClass. We then loop through each parameter of the method using the GetParameters method and print its name and type to the console. The IMethodInfo interface is part of the System.Reflection package library in C#.