using System;
public class Program
{
public static void Main()
Gen<int> genint = new Gen<int>();
genint.Add(5, 6);
Gen<string> genfloat = new Gen<string>();
string s1 = "hello";
string s2 = "world";
genfloat.Add(s1, s2);
}
/**
Below is the generic class. We define <T> to say that it is generic class.
Class has one method which takes two arguments of any type. It can be int, string, float or anything.
Check why we have used "dynamic" keyword on this article : https://www.tutorialsteacher.com/csharp/csharp-dynamic-type
**/
class Gen<T>
public T Add (T a1,T a2)
dynamic a = a1;
dynamic b = a2;
Console.WriteLine(a + b);
return a + b;