C# 参数param用法

public int  UseParams(params int[] list)
    {
        int c = 0;
        for (int i = 0; i < list.Length; i++)
        {
            c+=list[i];
        }
         return c;
    }
UseParams(1, 23, 4, 4, 5, 46, 5, 7, 65, 7, 6, 5, 8, 474);或
UseParams(new int[]{1,2,3,4,5,。。。。})或
UseParams()都可以
加了 params 的参数可以接受指定类型的数组。
posted @ 2016-01-15 16:35  立于群  阅读(3640)  评论(0)    收藏  举报