c# 方法中的 params 写法 static void Car( params string[] list){}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading.Tasks;


namespace xuexi
{
    class Program
    {

        static void Carr(params string[] list) { 
            for (int i = 0; i < list.Length; i++)
            {
                Console.WriteLine(list[i]); 
            }
        }

        static void Main(string[] args)
        {
            string[] ar = new string[5] { "我", "是", "中", "国", "人" };
            Carr(ar);
            Console.Read();
        }
    }

}
分类:

发表评论