Creating methods with infinite parameters?

后端 未结 8 1772
再見小時候
再見小時候 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

    You can achieve this by using the params keyword.

    Little example:

    public void AddItems(params string[] items)
    {
         foreach (string item in items)
         { 
             // Do Your Magic
         }
    }
    

提交回复
热议问题