Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This example shows how an array of objects is passed to the DisplayMyCollection method, which uses the params keyword to accept any number of arguments.
Example
class MyBoxingClass
{
public static void DisplayMyCollection(params object[] anArray)
{
foreach (object obj in anArray)
{
System.Console.Write(obj + "\t");
}
// Suspend the screen.
System.Console.ReadLine();
}
static void Main()
{
DisplayMyCollection(101, "Visual C# Basics", 2002);
}
}
Compiling the Code
You can compile the example directly using the command line, or paste it into a console application.