takes one
parameter and then a
integer array:
// Use regular parameter with a params parameter.
using System;
class MyClass {
public void ShowArgs(string msg, params int[] nums) {
Console.Write(msg + ": ");
foreach(int i in nums)
Console.Write(i + " ");
Console.WriteLine();
}
} class ParamsDemo2 {
MyClass ob = new MyClass();
ob.ShowArgs("Here are some integers",
1, 2, 3, 4, 5);
ob.ShowArgs("Here are two more",
17, 20);
} This program displays the following output:
C h a p t e r 8 :
A C l o s e r L o o k a t M e t h o d s a n d C l a s s e s
185