Questions: How do you invoke a method using reflection in C#? What is the purpose of the "dynamic" keyword in C#? How do you work with dynamic types in C#? What is the "var" keyword in C#? What is the purpose of the "out" keyword in C#? C# : Interview questions (91-95) Answers: 1. Invoking a Method Using Reflection in C#: To invoke a method using reflection in C#, you typically follow these steps: Get the Type of the class that contains the method using typeof or GetType() . Use GetMethod to obtain a MethodInfo object representing the method. Optionally, use GetParameters to get information about the method's parameters. Invoke the method using Invoke on an instance (for instance methods) or null (for static methods), passing in any required parameters. using System; using System.Reflection; public class Calculator { public int Add ( int a, int b ) { return a + b; } } public class Program { public stati...
Read - Revise - Recollect