zoukankan      html  css  js  c++  java
  • 关于params 用法

    params本身的含义是 某个方法需要的参数可能是不确定的,我们可以利用C#里的params关键字定义可变数目参数的方法

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace ConsoleApplication1
    {
        class Program
        {
            //如果是确定类型的就用 int ,string 等等。如果不是确定类型就用object
            //该参数必须为一维数组
            public static void User(params int[] list)
            {
                for (int i = 0; i < list.Length; i++)
                {
                    Console.WriteLine(list[i]);

                }
            }
            public static void User1(params object[] list)
            {
                for (int i = 0; i < list.Length; i++)
                {
                    Console.WriteLine(list[i]);
                }
            }
            static void Main(string[] args)
            {
                User(1, 2, 3);
                User1("haha", 1);
                User(1, 3, 4, 5, 4, 3, 3);
            }
        }
    }

  • 相关阅读:
    html控件使用
    托盤
    托盘的实现
    ws2s函数
    网络验证
    右上角X灰化
    如何模拟一个http请求并把response的内容保存下载下来,导出到excel中(结尾福利)
    排序的几种算法(一):冒泡排序
    python中的break eturnpasscontinue用法
    python中socket模块详解
  • 原文地址:https://www.cnblogs.com/huangmeimujin/p/2155610.html
Copyright © 2011-2022 走看看