Like it's name,
//using Generics in a class class tt<T> { public string add(T a,T b) { string c= a.ToString() + " " + b.ToString(); return c; } } tt<int> t = new tt<int>(); string ret = t.add(3,4); //3 4 tt<double> t2 = new tt<double>(); string ret2 = t2.add(3,4.54); //3 4.54 tt<string> t3 = new tt<string>(); string ret3 = t3.add("orange","good"); //orange good
public string add<T>(T a,T b) { string c= a.ToString() + " " + b.ToString(); return c; } string ret = add(3,4); //3 4 string ret2 = add(3,4.54); //3 4.54 string ret3 = add("orange","good"); //orange good