Forcing named arguments in C#

前端 未结 5 1294
忘了有多久
忘了有多久 2021-02-05 00:49

C# 4 introduced a feature called named arguments which is especially useful in scenarios like

int RegisterUser(string nameFirst, string nameLast, string nameMidd         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-02-05 01:38

    No, not in the C# language. It will always accept positional parameters if all the parameters are supplied.

    You could build a custom FxCop rule or an StyleCop rule to enforce this - as pointed out in the comments, it is likely a StyleCop rule you would be interested in (thanks to Kris).

提交回复
热议问题