سؤال

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