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!
One Response
The same syntax for ctor overloading 😉