Did you know that you can call a generic method with out supplying the type argument. The C# compiler will fill in the type parameter for you at compile time since the language is strongly typed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | static void MyMethod<S>(S myParam) { Console.WriteLine( typeof (S).ToString()); Console.WriteLine(myParam.GetType().ToString()); } static void Main( string [] args) { int a1 = 5; object a2 = 5; MyMethod(a1); MyMethod(a2); } /* //Outputs: System.Int32 System.Int32 System.Object System.Int32 */ |