Home   Cover Cover Cover Cover
 

Variable number of parameters

/csbook/solutions/08/A06.cs
using System;

class Test {
  
  static void Clear(int[] arr, params int[] indexes) {
    foreach (int i in indexes) arr[i] = 0;
  }
  
  public static void Main() {
    int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    Clear(a, 3, 4, 8);
    foreach (int val in a) Console.Write(val + " ");
    Console.WriteLine();
  }
}