I have the following class hierarchy
class A { public virtual string M() { return M(String.Empty); } public virtual string M(string s) { return M(s, false); } public virtual string M(string s, bool flag) {
Class B can be used in two cases:
1)
A b = new B(); string result = bM();
2)
B b2 = new B(); string result2 = b2.M(someString, true);
Both cases are thrown using a StackOverflowException. This is because base.M (s), which is called inside BM (string s, bool flag), will again call BM (string s, bool flag).
Is there a good way to avoid this?
I understand that if I call base.M (s, flag), everything will work, but what if someone else develops the dervived class and gets access to the .M (s) base? I don't like to leave a StackOverflowException here.
Decision
Now my hierarchy will look like
class A { public string M() { return M(String.Empty, false); } public virtual string M(string s, bool flag) {
source share