以下是示例代码
class Program
{
static void Main(string[] args)
{
Program prgm = new Program();
string sprgm = prgm.OverloadedMethod(null);
Console.ReadKey();
}
private string OverloadedMethod(object arg)
{
return "object as parameter";
}
private string OverloadedMethod(string arg)
{
return "string as parameter ";
}
}
当我传递null作为参数时。这是字符串重载方法和对象重载方法都可接受的值,但是为什么调用字符串重载方法呢?