Wie kann man in C# eine Funktion ausführen wenn man vorher nicht 100% weisst wieviel Parametrn die Funktion bekommt ?
Das ist ja eine komische Frage aber C# hat darauf eine Antwort.
static void Main(string[] args)
{
Foo(10, 20, 30);
Foo(1,2,3,4,5,6,7,8);
Foo(99,98);
}
static void Foo(params int[] numbers)
{
foreach (int i in numbers)
{
Console.WriteLine(i);
}
}
