10.1. Fundamentals of the try-catch-finally Construct

Instead of listing all the permutations of the try-catch-finally construct, we will work through the combinations by starting with a routine programming problem: efficiently determining whether a string can be parsed to a double value. If you're a procedural programmer, you probably tackle this by first iterating through the characters of the string and checking whether each character is a valid numeric or decimal point or has specific symbols such as E, +, /, or -. You then check whether the decimal point and the symbols are positioned correctly inside the string and ensure that they do not occur more than once. Then you must find whether the value is within the min-max range for a double. ...

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.