且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

默认参数指定不允许

更新时间:2023-11-14 23:26:10

根据你的错误信息,你可以这样做,在v3.5版本。

解决方法是多个构造函数:

 布尔listUnsubscribe(字符串apikey,
                     字符串ID,
                     串EMAIL_ADDRESS){
  返回listUnsubscribe(apikey,ID,EMAIL_ADDRESS,假的,真正的,真实的);
}

布尔listUnsubscribe(字符串apikey,
                     字符串ID,
                     串EMAIL_ADDRESS,
                     布尔delete_menber,
                     布尔send_goodbye,
                     布尔send_notify){
  返回什么;
}
 

I have the following code that gives the error

Default parameter specifiers are not permitted

How can this be fixed?

bool listSubscribe(string apikey,
                   string id, 
                   string email_address,
                   string [] merge_vars,
                   string email_type="html",
                   bool double_optin=false,
                   bool replace_interests=true,
                   bool send_welcome=false);

bool listUnsubscribe(string apikey, 
                     string id, 
                     string email_address, 
                     bool delete_menber=false,
                     bool send_goodbye=true,
                     bool send_notify=true);

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;
}