0
I have a method in which an attribute may not be used
In this case if the value passed is not empty it adds the parameter to my email
public async Task<bool> SendEmail(string to, string subject, string body,string unsubscribeHeaderUrl = "")
{
using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage())
{
if (!String.IsNullOrEmpty(unsubscribeHeaderUrl)) mail.Headers.Add("List-Unsubscribe",unsubscribeHeaderUrl);
}
}
But I can do it using the Overloading doing so:
public async Task<bool> SendEmail(string to, string subject, string body,string unsubscribeHeaderUrl = "")
{
using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage())
{
mail.Headers.Add("List-Unsubscribe",unsubscribeHeaderUrl);
//Restante do processo
}
}
public async Task<bool> SendEmail(string to, string subject, string body)
{
using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage())
{
//Restante do processo
}
}
What is the right way to do it? Use a if
or overloading