Reflection is a powerful feature in C# that allows you to inspect, manipulate, and call code at runtime. It provides the ability to analyze the metadata of an object, such as its type information, properties, methods, and attributes.

To use reflection in C#, you need to include the `System.Reflection` namespace:

“`csharp
using System.Reflection;
“`

Here are some common use cases for using reflection:

1. Getting the type of an object:
“`csharp
object obj = new MyClass();
Type type = obj.GetType();
“`

2. Creating an instance of a type dynamically:
“`csharp
Type type = typeof(MyClass);
object obj = Activator.CreateInstance(type);
“`

3. Getting all public methods of a type:
“`csharp
Type type = typeof(MyClass);
MethodInfo[] methods = type.GetMethods();
“`

4. Invoking a method dynamically:
“`csharp
object obj = new MyClass();
Type type = obj.GetType();
MethodInfo method = type.GetMethod(“MyMethod”);
method.Invoke(obj, null);
“`

5. Getting all properties of a type:
“`csharp
Type type = typeof(MyClass);
PropertyInfo[] properties = type.GetProperties();
“`

6. Getting the value of a property dynamically:
“`csharp
object obj = new MyClass();
Type type = obj.GetType();
PropertyInfo property = type.GetProperty(“MyProperty”);
object value = property.GetValue(obj);
“`

These are just some basic examples of what you can do with reflection in C#. Reflection is a powerful tool, but it should be used with caution as it can have performance implications and can make code less maintainable. Use reflection only when necessary and consider other alternatives whenever possible.