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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top