Does optional parameter and optional attribute not supported together?

后端 未结 1 1860
伪装坚强ぢ
伪装坚强ぢ 2021-01-29 06:53
public void ObjTest(StringBuilder sb, List list, int i = 0,  [Optional] string bs)
{
    ......
 }

The above code throwing compilation er

相关标签:
1条回答
  • 2021-01-29 07:21

    You can use them in conjunction but the optional parameter (the language construct) must be the last parameter in the parameter list.

    public void X(StringBuilder sb, List<string> list, [Optional] string bs, int i = 0)
    {
    }
    
    0 讨论(0)
提交回复
热议问题