moh*_*mar -6 .net c# params method-resolution-order
using System;
using System.Collections.Generic;
namespace Generics
{
class Minivan
{
public void foo(int z, int x)
{
Console.WriteLine("foo with two parameters");
}
public void foo(params int[] z)
{
Console.WriteLine("foo with two params parameter");
}
}
class D
{
public static void Main()
{
Minivan car3 = new Minivan();
car3.foo(10,20); // which method will be called here!!!
}
}
}
Run Code Online (Sandbox Code Playgroud)
哪个foo方法被调用?为什么?
| 归档时间: |
|
| 查看次数: |
87 次 |
| 最近记录: |