Feb. 13, 2011, 4:24 a.m.
posted by tekkero
Everything Ultimately Derives from System.ObjectGiven any object, whether a custom class or one built into the system, the methods shown in Figure will be defined.
All of these methods appear on all objects through inheritance; all objects derive (either directly or via an inheritance chain) from object. Even literals include these methods, enabling somewhat peculiar-looking code like this: Console.WriteLine( 42.ToString() ); Again, everything derives from object , even class definitions that don't have any explicit derivation. The two declarations for PdaItem in Listing 6.21, therefore, result in identical CIL. Listing 6.21. System.Object Derivation Implied When No Derivation Is Specified Explicitly
When the object's default implementation isn't sufficient, programmers can override one or more of the three virtual methods. Chapter 9 describes the details for doing this. |
- Comment