Ellipsis notation in C#?
Where can I get info about implementing my own methods that have the ellips开发者_高级运维is notation,
e.g.
static void my_printf(char* format, ...) { }
Also is that called ellipsis notation or is there a fancier name?
Have a look at the params keyword
From https://learn.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");
精彩评论