I want to overload my SET accessor.
Basically, if a string is passed as a parameter, I do a certain action (here, I created a new instance of the class Mailbox then I assign) or if it is an instance of Mailbox I assign directly .
Of overloading method what.
The problem is that the code No. 1 launches me compilation error (Error 2 The type 'CoreNet.Common.WebElement.MailStyle' already contains a definition for 'From') and the No. 2 code compiles well which is normal.
Code:
public string From
{
set
{
base.From = new MailAddress(value);
}
}
public MailAddress From
{
set { base.From = value;); }
}
Which ultimately would like this:
Code:
public void SetFrom (string Mail)
{
base.From = new MailAddress(Mail);
}
public void SetFrom(MailAddress Mail)
{
base.From = Mail;);
}
C# to implement this syntax to replace the methods SetXXXX Java, Java allows overloading of property of a SET, I do not understand why this is not possible in C#
How?
Bookmarks