Introducing System.Object2:28 with Jeremy McLain
Ah the omnipresent System.Object class.
[MUSIC] 0:00 It may surprise you to know that all types in C# inherit from a common base class. 0:04 That includes the classes that we make ourselves. 0:10 This common base class is system.object and it has a lot to offer. 0:13 In this part of the course, we'll get to know this common class. 0:18 System.Object offers many excellent examples 0:21 of how every class can take advantage of polymorphism and overriding methods. 0:25 To start, let's take a look at the documentation for 0:31 System.Object on the Microsoft Developer Network. 0:34 We can find this documentation by searching for System.Object. 0:37 Or you can click on the link in the teacher's notes. 0:44 Here it says that this is the ultimate base class of 0:47 all classes in the .NET Framework. 0:51 It is the root of the type hierarchy. 0:53 This is saying that all classes inherit from System.object, 0:56 even if we don't put :System.Object in our class declaration. 1:00 We can type it, 1:05 but it isn't required because all classes inherit from it anyway. 1:06 System.Object provides these eight methods. 1:09 I'll briefly explain what all these methods are and 1:13 we'll go into depth on a few of them. 1:16 First, we want to be familiar with the symbols to the left of the names of 1:19 the methods in the MSDN documentation. 1:22 The pink cube which appears to be on the move means that this is a method. 1:25 The yellow S means that the method is a static method, 1:30 meaning it can't be called on an instance of the class. 1:34 Only the class itself. 1:38 This little yellow key means that the method is protected. 1:40 So it can only be accessed from within the class and classes that inherit from it. 1:44 All of the non-static methods except GetType are virtual methods. 1:49 So they can be overridden in subclasses. 1:55 Static methods cannot be overridden in subclasses. 1:57 GetType returns an object of type Type. 2:01 This type with a capital T is a class that contains information about an object type. 2:05 Using GetType to get information about an object type 2:11 is commonly known as reflection. 2:14 You may have heard that term before. 2:17 Reflection is a topic for another course, so I won't go into it here. 2:19 Check the teacher's notes if you'd like to learn more. 2:23 Let's learn about these other methods. 2:26
You need to sign up for Treehouse in order to download course files.Sign up