两个重载
public int MyFun(params string[] values)
public int MyFun(string a,string b)调用时如果MyFun(c,d)
c,d都为string如何指定使用哪个重载,谢谢!

解决方案 »

  1.   

    MyFun(c,d)肯定是调用第二个方法,
    要指定,可以把c,d保存到一个string[]字符数组里,比如str,在MyFun(str),就可以了
      

  2.   

    默认会调用public int MyFun(string a,string b)因为两个都是String类型的,这个最合适,而不是第一个函数。
    因为第一个函数的第二个参数是数组类型的,而不是字符串的。只有超过了三个参数的才会调用第一个函数:public int MyFun(params string[] values)
      

  3.   

    哦,上面我说错了,只有两个参数且都是String的时候才会调用第二个。
      

  4.   

    Console.WriteLine (String, Object[])  Writes the text representation of the specified array of objects, followed by the current line terminator, to the standard output stream using the specified format information. 
    Supported by the .NET Compact Framework. Console.WriteLine (String, Object, Object)  Writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information. 
    Supported by the .NET Compact Framework. 
     
    Console.WriteLine (String, Object, Object, Object)  Writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information. 
    Supported by the .NET Compact Framework. 
     
    Console.WriteLine (String, Object, Object, Object, Object)  Writes the text representation of the specified objects and variable-length parameter list, followed by the current line terminator, to the standard output stream using the specified format information.  楼上能否解释一下为什么Console.WriteLine要提供多个重载 而不是只提供一个param Object[]