The question should be
Why in a generic-type method extension I don’t need to spell out a type when calling it?
Because the answer is precisely the inference that the compiler makes. The Enumarable.Range()
produces an enumerable type of int
. And the ToArray()
achieves this (probably unnecessarily), but does not change the type. So Shuffle()
, which is generic, can be inferred by the compiler that it is an integer that is manipulating.
In many cases the compiler is prepared to discover the type to be used, as long as it has this information quietly and simply, which is the case. It is no different than what allows you to use var
, compiler can identify which type is all that and let you omit the type.
Not everything the compiler can infer, and even some things that seem to give can be ambiguous, at least for the compiler that was not always created to see certain patterns, then you would have to make explicit.
It is better not to have to write when it is easily identifiable.
Then understand that there is as if using the var
, but even that is not necessary to write.