1 00:00:00,000 --> 00:00:04,822 [MUSIC] 2 00:00:04,822 --> 00:00:10,120 It may surprise you to know that all types in C# inherit from a common base class. 3 00:00:10,120 --> 00:00:13,240 That includes the classes that we make ourselves. 4 00:00:13,240 --> 00:00:18,190 This common base class is system.object and it has a lot to offer. 5 00:00:18,190 --> 00:00:21,175 In this part of the course, we'll get to know this common class. 6 00:00:21,175 --> 00:00:25,010 System.Object offers many excellent examples 7 00:00:25,010 --> 00:00:29,390 of how every class can take advantage of polymorphism and overriding methods. 8 00:00:31,090 --> 00:00:34,115 To start, let's take a look at the documentation for 9 00:00:34,115 --> 00:00:37,830 System.Object on the Microsoft Developer Network. 10 00:00:37,830 --> 00:00:44,030 We can find this documentation by searching for System.Object. 11 00:00:44,030 --> 00:00:46,140 Or you can click on the link in the teacher's notes. 12 00:00:47,350 --> 00:00:51,450 Here it says that this is the ultimate base class of 13 00:00:51,450 --> 00:00:53,960 all classes in the .NET Framework. 14 00:00:53,960 --> 00:00:56,590 It is the root of the type hierarchy. 15 00:00:56,590 --> 00:01:00,990 This is saying that all classes inherit from System.object, 16 00:01:00,990 --> 00:01:05,540 even if we don't put :System.Object in our class declaration. 17 00:01:05,540 --> 00:01:06,310 We can type it, 18 00:01:06,310 --> 00:01:09,875 but it isn't required because all classes inherit from it anyway. 19 00:01:09,875 --> 00:01:13,850 System.Object provides these eight methods. 20 00:01:13,850 --> 00:01:16,890 I'll briefly explain what all these methods are and 21 00:01:16,890 --> 00:01:19,230 we'll go into depth on a few of them. 22 00:01:19,230 --> 00:01:22,800 First, we want to be familiar with the symbols to the left of the names of 23 00:01:22,800 --> 00:01:25,650 the methods in the MSDN documentation. 24 00:01:25,650 --> 00:01:30,790 The pink cube which appears to be on the move means that this is a method. 25 00:01:30,790 --> 00:01:34,830 The yellow S means that the method is a static method, 26 00:01:34,830 --> 00:01:38,320 meaning it can't be called on an instance of the class. 27 00:01:38,320 --> 00:01:40,190 Only the class itself. 28 00:01:40,190 --> 00:01:44,350 This little yellow key means that the method is protected. 29 00:01:44,350 --> 00:01:49,960 So it can only be accessed from within the class and classes that inherit from it. 30 00:01:49,960 --> 00:01:55,050 All of the non-static methods except GetType are virtual methods. 31 00:01:55,050 --> 00:01:57,910 So they can be overridden in subclasses. 32 00:01:57,910 --> 00:02:01,290 Static methods cannot be overridden in subclasses. 33 00:02:01,290 --> 00:02:05,080 GetType returns an object of type Type. 34 00:02:05,080 --> 00:02:11,330 This type with a capital T is a class that contains information about an object type. 35 00:02:11,330 --> 00:02:14,700 Using GetType to get information about an object type 36 00:02:14,700 --> 00:02:17,440 is commonly known as reflection. 37 00:02:17,440 --> 00:02:19,270 You may have heard that term before. 38 00:02:19,270 --> 00:02:23,720 Reflection is a topic for another course, so I won't go into it here. 39 00:02:23,720 --> 00:02:26,300 Check the teacher's notes if you'd like to learn more. 40 00:02:26,300 --> 00:02:27,940 Let's learn about these other methods.