Default parameter specifiers are not permitted

后端 未结 4 1424
无人共我
无人共我 2020-12-10 05:35

I have the following code that gives the error

Default parameter specifiers are not permitted

How can this be fixed?

相关标签:
4条回答
  • 2020-12-10 06:09

    I just now encountered this error and my project is also targeting 4.0 and not 3.5 or below.

    I toggled it to 3.5 and then back to 4.0 and then the error went away. Hopefully these steps will work for you, or someone else.

    0 讨论(0)
  • 2020-12-10 06:13

    Optional parameters are a feature of C# 4, not present in earlier versions. Since you're using .NET 3.5, you can't use optional parameters.

    Either switch to .NET 4.0, or use overloaded methods instead.

    0 讨论(0)
  • 2020-12-10 06:21

    As per your error message, you can't do that in v3.5.

    The work around is multiple constructors:

    bool listUnsubscribe(string apikey, 
                         string id, 
                         string email_address) {
      return listUnsubscribe(apikey, id, email_address, false, true, true);
    }
    
    bool listUnsubscribe(string apikey, 
                         string id, 
                         string email_address, 
                         bool delete_menber,
                         bool send_goodbye,
                         bool send_notify) {
      return whatever;
    }
    
    0 讨论(0)
  • 2020-12-10 06:32

    The application/class library is not set to target .NET 4 Framework. Adjust in the project's settings page.

    enter image description here

    0 讨论(0)
提交回复
热议问题