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); 
    //看也可以是容器类,可变吧:)
            }

    }
  • 相关阅读:
    推自己的镜像到网易云
    supervisord常见问题
    supervisord的配置
    一文解读SDN (转)
    一文解读ZooKeeper (转)
    使用 Docker 和 Nginx 打造高性能的二维码服务 (转)
    一文解读Docker (转)
    一文解读分布式架构 (转)
    一文解读分布式事务 (转)
    一文读懂工业大数据 (转)
  • 原文地址:https://www.cnblogs.com/xiaobaigang/p/844497.html
Copyright © 2011-2022 走看看