Limit number of parameters per method?

前端 未结 5 926
离开以前
离开以前 2021-02-19 07:57

Assuming the parameters are all the same type, is there a rule of thumb in regards to the number of parameters for a method? Im just wondering where I should draw the line and

5条回答
  •  迷失自我
    2021-02-19 08:30

    If you will be passing an unknown number of arguments, you should use varargs or pass a IEnumerable. Of course, sometimes you pass a fixed number of items of the same type. In the latter case, the fixed number should follow from the method's purpose.

提交回复
热议问题