Monday, 12 January 2009

C# params keyword

public class MyClass 
{
  public static void UseParams(params int[] list) 
  {
    for ( int i = 0 ; i < list.Length ; i++ )
    {
      Console.Write(string.format("{0},",list[i]));
    }
  }

  public static void Main()
  {
    UseParams(1); //1,
    UseParams(1,2,3); //1,2,3,
  }
}

No comments:

Post a Comment