Question

Where can I get info about implementing my own methods that have the ellipsis notation,

e.g.

static void my_printf(char* format, ...) { }

Also is that called ellipsis notation or is there a fancier name?

Was it helpful?

Solution

Have a look at the params keyword

OTHER TIPS

From https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/params:

By using the params keyword, you can specify a method parameter that takes a variable number of arguments.

You can send a comma-separated list of arguments of the type specified in the parameter declaration or an array of arguments of the specified type. You also can send no arguments. If you send no arguments, the length of the params list is zero.

static void MyPrintf(string format, params object[] args) { }

...

MyPrintf(1, 'a', "test");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top