P
puzzlecracker
I encountered this problem while having code in the following form:
public class Base:IFormattable
{
public string ToString(string format, IFormatProvider
formatProvider)
{
// Do some stuff here
}
public override String ToString() { return ToString(null,
null); }
}
public class Derived1:Base
{
public override String ToString() { return ToString(null,
null); }
public new string ToString(string format, IFormatProvider
formatProvider)
{ }
}
public class Derived2:Base
{
public override String ToString() { return ToString(null,
null); }
public new string ToString(string format, IFormatProvider
formatProvider)
{ }
}
Discussion: The mandatory usage of the keywords 'new' and 'override'
not only befuddle me, but also appear as if they add more mess to the
code. I think the new shouldn't be required in this case just because
we have two ToString member methods. WHY WHY WHY
What's the point to have us programmers write in this way?
Thanks
public class Base:IFormattable
{
public string ToString(string format, IFormatProvider
formatProvider)
{
// Do some stuff here
}
public override String ToString() { return ToString(null,
null); }
}
public class Derived1:Base
{
public override String ToString() { return ToString(null,
null); }
public new string ToString(string format, IFormatProvider
formatProvider)
{ }
}
public class Derived2:Base
{
public override String ToString() { return ToString(null,
null); }
public new string ToString(string format, IFormatProvider
formatProvider)
{ }
}
Discussion: The mandatory usage of the keywords 'new' and 'override'
not only befuddle me, but also appear as if they add more mess to the
code. I think the new shouldn't be required in this case just because
we have two ToString member methods. WHY WHY WHY
What's the point to have us programmers write in this way?
Thanks