O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

6.4. Looking at System.Object

Here's something that makes C# look more like Java than its official ancestor C++.

Like Java

  • Only single class inheritance is supported in C#. A C# class can implement multiple interfaces. [5]

    [5] C++ supports multiple class inheritance and does not support interfaces.

  • All Java classes are implicitly subclasses of java.lang.Object. In C#, all classes are implicitly subclasses of System.Object. [6] This implies that all C# classes must have one, and only one direct superclass, except for System.Object.

    [6] There are several advantages of having all your classes share a common ancestry. At the very least, you are assured that whatever object a method returns can be referenced by a variable of type System.Object. Also, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required