Quantcast
Channel: Clive Ciappara - Developer for Apps & Websites » Quickie
Viewing all articles
Browse latest Browse all 13

C# | Call Overloaded Methods

$
0
0
Sometimes in C#, to call overloaded methods within the same method names, we still use the old method. In C# there is a neater way to pass arguments to overloaded methods which can be seen below:
Old Way

public MultiLineString(string text)
{
MultiLineString(text, false);
}

public MultiLineString(string text, bool allowEmptyLines)
{
...
}

Neater C# Way

public MultiLineString(string text)
: this(text, false)
{
}

public MultiLineString(string text, bool allowEmptyLines)
{
...
}

Hope this helps!

Viewing all articles
Browse latest Browse all 13

Trending Articles