concept typeof in category c#

This is an excerpt from Manning's book Code like a Pro in C#.
Welcome to the deep end. Listing 4.1 is a fair bit of code with a lot of things that may be new to us. All endpoints in the controller look similar to this one. They all use the same patterns to get the data and to return it, so after we fully understand what is happening here, the other endpoints are going to be be a breeze. In this section, we look at the method signature of the
/flight’sGetmethod. We start by examining theResponseTypemethod attribute, followed by a discussion on thetypeofkeyword and what it does. Lastly, we glimpse how theResponseTypemethod attribute uses theIEnumerableinterface andtypeofoperator. What does the method signature look like?

This is an excerpt from Manning's book C# in Depth.
13 Boxing will always occur when you call GetType() on a value type variable, because it can’t be overridden. You should already know the exact type if you’re dealing with the unboxed form, so you can just use typeof instead.
As a further complication, types can be open or closed. An open type is one that still involves a type parameter (as one of the type arguments, or as the array element type, for example), whereas a closed type is one that isn’t open; every aspect of the type is known precisely. All code actually executes in the context of a closed constructed type. The only time you’ll see an unbound generic type within C# code (other than as a declaration) is within the typeof operator, which you’ll meet in section 3.4.4.
Reflection is used by different people for all sorts of things. You might use it for execution-time introspection of objects to perform a simple form of data binding. You might use it to inspect a directory full of assemblies to find implementations of a plugin interface. You might write a file for an inversion of control framework (see www.martinfowler.com/articles/injection.html) to load and dynamically configure your application’s components. As the uses of reflection are so diverse, I won’t focus on any particular one but will instead give you more general guidance on performing common tasks. We’ll start by looking at the extensions to the typeof operator.
Reflection is all about examining objects and their types. As such, one of the most important things you need to be able to do is obtain a reference to a particular System.Type object, which allows access to all the information about that type. C# uses the typeof operator to obtain such a reference for types known at compile time, and this has been extended to encompass generic types.
There are two ways of using typeof with generic types—one retrieves the generic type definition (in other words, the unbound generic type) and one retrieves a particular constructed type. To obtain the generic type definition—the type with none of the type arguments specified—you simply take the name of the type as it would’ve been declared and remove the type parameter names, keeping any commas. To retrieve constructed types, you specify the type arguments in the same way as you would to declare a variable of the generic type. The next listing gives an example of both uses. It uses a generic method so we can revisit how typeof can be used with a type parameter, which we previously saw in 3.8.
Listing 3.11. Using the typeof operator with type parameters
static void DemonstrateTypeof<X>() { Console.WriteLine(typeof(X)); #1 Console.WriteLine(typeof(List<>)); #2 Console.WriteLine(typeof(Dictionary<,>)); Console.WriteLine(typeof(List<X>)); #3 Console.WriteLine(typeof(Dictionary<string,X>)); Console.WriteLine(typeof(List<long>)); #4 Console.WriteLine(typeof(Dictionary<long,Guid>)); } ... DemonstrateTypeof<int>(); #1 – Displays method’s type parameter #2 – Displays generic types #3 – 1 Displays closed types (despite using type parameter) #4 – Displays closed types !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[]"} !@%STYLE%@!