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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.