Explicit type parameters C# with Example
There are different cases where you must Explicitly specify the type parameters for a generic method. In both of the below cases, the compiler is not able to infer all of the type parameters from the specified method parameters. One case is when there are no parameters: public void SomeMethod() { // No code for simplicity } SomeMethod(); // doesn't compile SomeMethod(); // compiles Second case is when one (or more) of the type parameters is not part of the method parameters: public K SomeMethod(V input) { return default(K); } int num1 = SomeMethod(3); // doesn't compile int num2 = SomeMethod("3"); // doesn't compile int num3 = SomeMethod("3"); // compiles.