The typeof Operator: A Sneak Peek at Reflection

One of the big advantages of having metadata baked in to the runtime is the capability to provide reflection capabilities. Tools can use metadata to provide designer experiences by providing property grids to configure items that need configuration (for example, user interface [UI] controls). Via reflection, that metadata is readily available at runtime.

The most common starting point for use of reflection is at the type level. Suppose that we want to know all the properties a type exposes. For example, a Button control could have a Width and Height of type double and a Text of type string. Or the built-in DateTime type has properties like Day, Month, Year, and so on. So, what we need is a runtime ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.