Generic methods <string> vs <T,U>
I didn't understand the explanation in the lesson If you have a single type parameter you need to explicitly name it ? string x = "Hello"; string y = "World"; Swap<string>(ref x, ref y);//<----- <string> //Now x is "World", y is "Hello" If you have 2 different type of parameters do not need to name the type explicitly. static void Func<T, U>(T x, U y) { Console.WriteLine(x+" "+y); } static void Main(string[] args) { double x = 7.42; string y = "test"; Func(x, y); //<---- I would expect something like Func<string, double>(x,y); } Why is it that if you have a single parameter in a generic method you need to name the type like Swap<string>(ref a, ref b) and if you have more parameters you do not need it like Func(x,y) It does work though https://code.sololearn.com/cwlo7qP7T8rR