/* Learning C# by Jesse Liberty Publisher: O'Reilly ISBN: 0596003765 */ using System; namespace ParamsDemo { public class TesterParamsDemo { public void Run() { int a = 5; int b = 6; int c = 7; Console.WriteLine("Calling with three integers"); DisplayVals(a,b,c); Console.WriteLine(" Calling with four integers"); DisplayVals(5,6,7,8); Console.WriteLine(" calling with an array of four integers"); int [] explicitArray = new int[4] {5,6,7,8}; DisplayVals(explicitArray); } // takes a variable number of integers public void DisplayVals(params int[] intVals) { foreach (int i in intVals) { Console.WriteLine("DisplayVals {0}",i); } } [STAThread] static void Main() { TesterParamsDemo t = new TesterParamsDemo(); t.Run(); } } }