Reflection is one of those features every .Net/C# developer has used directly or indirectly. This article walks through — using a dynamic email template engine as the running example — and then tours a few real-life use cases where reflection does real work.

What Is Reflection?

Reflection lets code inspect and interact with types, methods, properties, and assemblies at runtime — even ones it didn't know about at compile time. It lives in the System.Reflection namespace and has been part of .NET since .NET Framework 1.0 in 2002.

Type type = someObject.GetType();

PropertyInfo[] properties = type.GetProperties();