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);
            }
        }
    }

  • 相关阅读:
    Numpy 里线性代数函数
    lateral view 使用方法
    Numpy 基础函数
    Numpy 基础操作
    pandas 基础操作记录学习
    pandas向左移动非空单元格
    供应商自动记账
    SAP Smartforms 参数配置
    SAP FPM 相关包 APB_FPM_CORE
    SAP BPC 清除CUBE 中的数据
  • 原文地址:https://www.cnblogs.com/huangmeimujin/p/2155610.html
Copyright © 2011-2022 走看看