It is posible in C# to decide in constructor, which other override constructor use? This below code doesn't compile! I don't know which invocation use.
public IntRange(int val, bool isMax)
: isMax ? this() : this()
{
if (isMax)
{
IntRange(0, val);
}
else
{
IntRange(val, int.MaxValue);
}
}
How about:
class IntRange {
public IntRange(int val, bool isMax)
: this(isMax ? 0 : val, isMax ? val : int.MaxValue) {
}
public IntRange(int min, int max) {
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With