Generics Class:
using System; namespace GenericsClass { class GenericClass<T> { public GenericClass(T msg) { Console.WriteLine(msg); } } class Program { static void Main(string[] args) { GenericClass<string> gen=new GenericClass<string>("This is generic class"); GenericClass<int> inrr=new GenericClass<int>(101); GenericClass<char> getCh=new GenericClass<char>('I'); Console.ReadKey(); } } }
Generics method:
using System; namespace GenericMEthod { class GenericClass { public void Show<T>(T msg) { Console.WriteLine(msg); } } class Program { static void Main(string[] args) { GenericClass genc=new GenericClass(); genc.Show("This is generic method"); genc.Show(101); genc.Show('I'); Console.ReadKey(); } } }