views:

211

answers:

2

When reading the tutorial of "Properties Tutorial" from MSDN. I'm consused about the example.

How to define abstract properties. ...

When I debug, I found each of the three override double Area() is invoked by ToString(); and ToString() is invoked default by the WriteLine() calls.

What's the benefit calling this way? I feel it is not a short way to override double Area().

   public override string ToString()
   {
      return Id + " Area = " + string.Format("{0:F2}",Area);
   }
+3  A: 

The ToString/writeline methods are not related to overriding Area, it is a demonstration to show the use of an overriden property.

Paul Creasey
+1  A: 

This is just a demo, the author simplely like this way to demo the code I think, but there's no relationships between them.

redjackwong