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,
  }
}

Comments

Popular posts from this blog

Parse XML to dynamic object in C#

C# Updating GUI from different thread