Creating methods with infinite parameters?

后端 未结 8 1700
再見小時候
再見小時候 2021-01-31 13:44

In C# you can do this:

foo = string.Format(\"{0} {1} {2} {3} ...\", \"aa\", \"bb\", \"cc\" ...);

This method Format() accepts in

8条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-31 14:41

    use the params keyword. For example

    static void Main(params string[] args)
    {
        foreach (string arg in args)
        {
            Console.WriteLine(arg);
        }
    }
    

提交回复
热议问题