C
C#2y ago
Raki

❔ Optional parameter throwing error

I have a method

public UserAccount CreateOrUpdateUserAccountWithEmailSubscriptions
(string email, bool isNewsletterSubscribed, out bool isExists, bool signUp = false)
{

}

public UserAccount CreateOrUpdateUserAccountWithEmailSubscriptions
(string email, bool isNewsletterSubscribed, out bool isExists, bool signUp = false)
{

}
On calling this method like
_authenticationService.CreateOrUpdateUserAccountWithEmailSubscriptions(user.Email, viewModel.PatientInfoEmailEnabled, out var isExists);
_authenticationService.CreateOrUpdateUserAccountWithEmailSubscriptions(user.Email, viewModel.PatientInfoEmailEnabled, out var isExists);
It throws the error like screenshot error message. I don't want to send the optional parameter while passing since i believe it should take what i have specified in the method.
5 Replies
Angius
Angius2y ago
$codegif
Angius
Angius2y ago
I'd just work around it by overloading the method instead of using an optional parameter tbh No idea why the error happens, though
Saber
Saber2y ago
The interface needs the default value if it doesn't afaik
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server