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

    }
  • 相关阅读:
    TTFB
    区分数组与对象
    单点登录使用163邮箱
    从其它系统登录到SharePoint 2010系统的单点登录
    js 弹出对话框3种方式
    PowerShell编辑
    修改SharePoint页面上的控件数量的限制
    在SharePoint 2010页面中嵌入SWF文件
    修改SharePoint列表项显示“新”图标的天数
    JSP页面显示乱码
  • 原文地址:https://www.cnblogs.com/xiaobaigang/p/844497.html
Copyright © 2011-2022 走看看