例如
public void test(params string[] args)
{
   //怎么在args的最前面增加一项
   //args.push("一项新的");
   MessageBox.Show(string.Format("{0}{1}{2}{3}",args));
}

解决方案 »

  1.   

    static void Main(string[] args)
    {
        test("1", "2", "3");
    }public static void test(params string[] args)
    {
        args = new string[] { "新的" }.Concat(args).ToArray();
        Console.WriteLine(string.Format("{0}{1}{2}{3}", args));
    }
      

  2.   

    那就新建一个数组,复制过去不就得了。代码由你写了,别人还有什么特别的要求吗?            string[] more = new string[args.Length + 1];
                
                more[0] = "一项新的";
                Array.Copy(args, 0, more, 1, args.Length);            MessageBox.Show(string.Format("{0}{1}{2}{3}", more)); //args));
    或者格式已固定,不嫌麻烦就这样:
    MessageBox.Show(string.Format("{0}{1}{2}{3}", "一项新的", args[0], args[1], args[2]));
      

  3.   

    如果只是像代码中这样简单拼接,用String.Join就好了:    //如果args的长度固定为3的话
        MessageBox.Show("一项新的" + string.Join("", args));    //否则
        MessageBox.Show("一项新的" + string.Join("", args, 0, 3));
      

  4.   

    解决了,利用ArrayList中转处理,问题是只能返回object[]