All classes derived from class System.Object
(ultimate base class of all classes in the .NET Framework).
Class Shape
in the example is overriding ToString()
method from class System.Object.
题
I am currently reading this article from MSDN (which is also here). As a newbie, I can't figure out why there is an override
method within an abstract class:
public override string ToString()
{
return Id + " Area = " + string.Format("{0:F2}",Area);
}
I thought override
is used to provide/override implementation after extending from an abstract or virtual class, but I don't understand why there's an override
method within an abstract class.
解决方案
All classes derived from class System.Object
(ultimate base class of all classes in the .NET Framework).
Class Shape
in the example is overriding ToString()
method from class System.Object.