Does C# support a variable number of arguments, and how?

前端 未结 4 944
自闭症患者
自闭症患者 2020-11-27 19:17

Does C# support a variable number of arguments?

If yes, How does C# support variable no of arguments?

What are the examples?

How are variable argum

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 19:55

    Yes, params:

    public void SomeMethod(params object[] args)
    

    params has to be the last argument and can be of any type. Not sure if it has to be an array or just an IEnumerable.

提交回复
热议问题