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

13.2. C# exception hierarchy

Like Java, all exception classes are subclasses of one special exception class. [8] In Java, it is java.lang.Exception; [9] in C# the grandfather of all exception classes is System.Exception.

[8] C++ developers will find this a new idea. In C++, anything can be an exception – there is no rule to say that exceptions must be instances of any special class.

[9] Which is in turn a direct subclass of java.lang.Throwable. For Java, Throwable is a direct subclass of java.lang.Object. From Throwable, we have java.lang.Error and java.lang.Exception. C# does not differentiate between exceptions and errors.

Figure 13.4 shows some significant predefined exception classes in C#.

Figure 13.4. System.Object and some C# exception classes. ...

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