+ 1

Multiple Generic parameter

I did not get multiple generic parameter <T,U> what is the use of it ? why we can't use <T,T> because in <T> it can takes all types?

4th Oct 2016, 5:00 AM
arti tripathi
arti tripathi - avatar
3 Respuestas
0
You can't use <T,T> because it makes no sense. Use <T> then. Effect is the same, but it is allowed. Multiple generic parameter is used by Dictionary type, for example. First parameter is for key, and second is for value.
4th Oct 2016, 9:07 PM
Ivan G
Ivan G - avatar
0
I didnt get what you want to reach by your quesion, anyways.. the generic parameter <T,T> is pointless, why? Because AS IN MATHs, if you have 2 formulas each one has the value X, and X is given a value of 5 for example, then, this 5 is in both formulas, same thing in Generics, <T,T> means two type parameters each one is same as the other, so when you use it, you can only apply 2 same types, Like <int,int> and that takes you to nowhere. But <T,U> means two DIFFERENT types each one has its settings in the method you are adding those parameters to.
19th Jul 2017, 2:43 PM
Abdulaziz Almawash
Abdulaziz Almawash - avatar
0
The goal of using two different letters as in <T,U> is to tell that each letter is different then the other which ALSO means two different types in implementation.
19th Jul 2017, 2:45 PM
Abdulaziz Almawash
Abdulaziz Almawash - avatar