Why is the result equal to "Test with int was called!" Instead of "Test with object was called!"?
Converting to int "better" than converting to object , so overloading that takes int is "better" than one that accepts object , and both are applicable as short implicitly converted to both int and object . ( long overloading is also applied, but converting to int better than long ).
See section 7.5.3 of the C # language specification for general overload rules and 7.5.3.3 for "best conversion" rules. It makes little sense to write them here, since they are very long, but the most important aspect is that there is a conversion from int to object , but without conversion from object to int - therefore, conversion to int is more specific and therefore better.
(Partition numbers are given in versions C # 4 and C # 5. You can download C # 5 spec in Word format.)
source share