concept generic type in category c#

This is an excerpt from Manning's book C# in Depth, Fourth Edition.
Listing 2.8. Exploring static fields in generic types
class GenericCounter<T> { private static int value; #1 static GenericCounter() { Console.WriteLine("Initializing counter for {0}", typeof(T)); } public static void Increment() { value++; } public static void Display() { Console.WriteLine("Counter for {0}: {1}", typeof(T), value); } } class GenericCounterDemo { static void Main() { GenericCounter<string>.Increment(); #2 GenericCounter<string>.Increment(); GenericCounter<string>.Display(); GenericCounter<int>.Display(); #3 GenericCounter<int>.Increment(); GenericCounter<int>.Display(); } }
The values of the arguments are used as the initial values for the parameters within the method. In generics, you have type parameters and type arguments, which are the same idea but applied to types. The declaration of a generic type or method includes type parameters in angle brackets after the name. Within the body of the declaration, the code can use the type parameter as a normal type (just one it doesn’t know much about).
The code using the generic type or method then specifies the type arguments in angle brackets after the name as well. Figure 2.2 shows this relationship in the context of List<T>.

This is an excerpt from Manning's book C# in Depth.
The primary new feature in C# 2 regarding the type system is the inclusion of generics. It largely addresses the issues I raised in section 2.2.2 about strongly typed collections, although generic types are useful in a number of other situations too. As a feature, it’s elegant, it solves a real problem, and despite a few wrinkles it generally works well. You’ve seen examples of this in quite a few places already, and it’s described fully in the next chapter, so I won’t go into any more detail here. Generics form probably the most important feature in C# 2 with respect to the type system, and you’ll see generic types throughout the rest of the book.
In this chapter, we’ll look at how to use generic types and methods that others have provided (whether in the framework or as third-party libraries), and how to write your own. Along the way, we’ll look at how generics work with the reflection calls in the API, and at a bit of detail around how the CLR handles generics. To conclude the chapter, I’ll present some of the most frequently encountered limitations of generics, along with possible workarounds, and compare generics in C# with similar features in other languages.
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.

This is an excerpt from Manning's book Real-World Functional Programming with Examples in F# and C#.
The second example is much more interesting. You can see how lists are created under the covers: we take an empty list and use a syntax for creating a cons cell ::. Unlike operators such as +, the :: construct is right associative, which means that it composes values from the right to the left. If you read the expression in that direction, you can see that we construct a list cell from a value of 3 and an empty list, then use the result together with a value of 7 to construct another cell, and so on. After entering the expression, F# Interactive reports that we created a list of type int list. This means that the type of the ls2 value is a list that contains integers. This is again done using generic types that you may know from C# (and you’ll see how to use them in F# in detail later).
In this section we’ll talk about generic type declarations, and you’ll see that in many ways generic types in F# are similar to generic types in C#. We’ve only seen one kind of type declaration so far—the discriminated union, declared with the type construct. We’ll see other type declarations that can be written using the same construct later (in particular, in chapters 7 and 9), but the syntax for making them generic is exactly the same as the syntax we’ll see now.