【发布时间】:2013-09-25 17:51:45
【问题描述】:
给定以下重载方法:
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!"?
【问题讨论】:
标签: c# overloading