zoukankan      html  css  js  c++  java
  • 參數不確定時構造函數的方法

    方法:在函數聲明中使用params 聲明數組作為參數,該數組沒有具體長度。
    實例:

    public static void UseParams(params int[] list)
    {
          for (int i = 0 ; i < list.Length; i++)
         {  
             Console.WriteLine(list[i]);
          } 
    }
    static void Main()
    {
    UseParams(1, 2);
    UseParams(1, "abc", 3,"AAA");
    int[] myarray = new int[3] {10,11,12};
    UseParams(myarray);
    }
  • 相关阅读:
    11.MySQL
    10、设计模式
    9
    8
    7
    6
    5
    4
    3
    2
  • 原文地址:https://www.cnblogs.com/tianxiang2046/p/1368749.html
Copyright © 2011-2022 走看看