When chaining constructors, in C#, how can I easily tell whether or not the constructor was called directly, or was called by another constructor using this?
public Test() : this(string.Empty, string.Empty) {}
public Test(string helloworld) : this(helloworld, string.Empty){}
public Test(string helloworld, string goodbyeworld)
{
//do work
}
If for some reason you really NEED to do this (and you pretty much never need to) this can be accomplished by making your “Master” constructor private or protected and adding another argument that indicates which other constructor was used.
I realize this is sort of a ridiculous answer but the problem is kind of ridiculous as well.