C# Generic Methods

In my previous post, I explained about Generics. C# also provides Generic Methods. We can create a method which defer the parameter data type until the method is called. These parameters are called Type parameters that means we can pass the actual data type later. Below is the example of Generic Method. static void Swap<T>(ref T input1, ref T input2) { T temp = default(T); ...

Continue Reading

C# Generics

Generics are introduced in C# 2.0. It is the most powerful features of C#. In C# 1.0, when we design a class that use other types that is not known at defining the structure of the class, then type should be an object type. In the class, we have to typecast the type using boxing and unboxing and then we can use the type. Generics introduced the concept of type parameters. With the type paramet...

Continue Reading