10.6. Summary

The .NET CLR supports exception handling in the form of a Java-style try-catch-finally construct. Here are the key points to keep in mind about C# exception handling:

  • A try block must be followed by one or more catch blocks or by a finally block, or both.

  • The most general exception needs to be caught in the last catch block.

  • A try-catch block can be nested. Exceptions bubble up the execution stack to outer try-catch blocks. Any uncaught exceptions bubble up the method call stack until they are handled by the CLR.

  • Like Java, C# has one System.Exception class from which all other exception classes inherit.

  • C# does not support checked exceptions, unchecked exceptions, or errors.

  • C# allows implementing classes to throw exceptions that are ...

Get .NET for Java Developers: Migrating to C# now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.