Getting the Type’s Reflection Info Object

The other operation that’s meaningfully defined on a generic parameter T is the typeof expression that gets the System.Type object describing, at runtime, the type that was supplied for the type parameter T:

image

Because you’ll be reading a whole chapter about reflection (Chapter 21, “Reflection”), we defer further discussion about System.Type until later. Practically speaking, you should rarely have to use the typeof(T) trick.

Get C# 4.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.