optional parameters must appear after all required parameters in c# [duplicate]

半城伤御伤魂 提交于 2019-11-29 18:49:17
Selman Genç

You need to move your optional parameters to the end of the parameter list:

from MSDN:

Optional parameters are defined at the end of the parameter list, after any required parameters. If the caller provides an argument for any one of a succession of optional parameters, it must provide arguments for all preceding optional parameters. Comma-separated gaps in the argument list are not supported. For example, in the following code, instance method ExampleMethod is defined with one required and two optional parameters.

public List<IndentItems> GetIndentFilledInfo(
        List<SurveyFeedback> surveyFeedbacks, 
        bool hasupdate,
        string ddlevent,
        string indentType = null)

More Read Here

optional params should be after all of you method params:

public List<IndentItems> GetIndentFilledInfo(
    List<SurveyFeedback> surveyFeedbacks, 
    bool hasupdate, 
    string ddlevent,
    string indentType = null)    
{
    // Codes here
}

MSDN

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!