Chapter 13. Exception handling

If you are a Java developer, C#'s exception handling mechanism is very similar to Java's, and you will feel very comfortable. [1] There are, of course, new things to learn – C# has done away with checked exceptions and built in something called inner exceptions, as well as other minor improvements.

[1] VB 6 developers will find exception handling a totally new thing to pick up when they move over to VB .NET. VB 6 has no proper exception handling mechanism, and developers rely on the ancient On Error Goto construct to handle errors.

C# has four keywords for exception handling – try, catch, finally, and throw. Notice that C# does not have the throws keyword which Java developers use when declaring methods.

I shall ...

Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.