zoukankan      html  css  js  c++  java
  • Params参数的应用

    public partial class Form1 : Form
        
    {
            
    public static void UseParams(params int[] list)
            
    {
                
    string temp = "";
                
    for (int i = 0; i < list.Length; i++)
                    temp 
    = temp +" " +list[i].ToString();
                MessageBox.Show(temp);
            }

     
            
    public static void UseParams2(params object[] list)
            
    {
                
    string temp = "";
                
    for (int i = 0; i < list.Length; i++)
                    temp 
    = temp + " " + list[i].ToString();
                MessageBox.Show(temp);
            }
     
     
            
    public Form1()
            
    {
     InitializeComponent();
            }

     
            
    private void button1_Click(object sender, EventArgs e)
            
    {
                UseParams(
    123);//看参数是3个
                UseParams(12);   //看参数是2个,可变吧
     
     
                UseParams2(
    1'a'"test");
     
                
    int[] myarray = new int[3101112 };
                UseParams(myarray); 
    //看也可以是容器类,可变吧:)
            }

    }
  • 相关阅读:
    对于global的介绍
    elang和python互通的例子
    gen_server的一些心得
    erlang分布式例子
    erlang热部署
    erlang配置三方库
    opencv学习之PyImageSearch
    雅克比矩阵
    罗德里格斯公式的证明
    opencv学习网站
  • 原文地址:https://www.cnblogs.com/xiaobaigang/p/844497.html
Copyright © 2011-2022 走看看