using System; namespace ConsoleApplication8 { class Program { static void Main(string[] args) { SetData(); SetData(5); SetData(new int[] { 1, 3, 5, 7, 9 }); Console.ReadKey(); } static void SetData(params int[] data) { for (int i = 0; i < data.Length; i++) { Console.WriteLine(data[i]); } Console.WriteLine("-----------"); } } }
參考資料:
http://msdn.microsoft.com/zh-tw/library/w5zay9db(v=vs.90).aspx