给定以下重载方法:
public string Test(long item)
{
return "Test with a long was called!";
}
public string Test(int item)
{
return "Test with an int was called!";
}
public string Test(object item)
{
return "Test with an object was called!";
}
当我打电话时Test()
,传递一个short
,像这样:
short shortValue = 7;
var result = Test(shortValue);
为什么值result
等于"Test with an int was called!"
,而不是"Test with an object was called!"
?