Thargy.com

Blogs and articles by Craig Dean

Null

The problem with null checking

The .NET framework is littered with the following code (e.g. from the System.Guid class): public static Guid ParseExact(String input, String format) { if (input == null) throw new ArgumentNullException(“input”); if (format == null) throw new ArgumentNullException(“format”); if (format.Length != 1) { // all acceptable format strings are of length 1 throw new FormatException(…); } … […]

, , ,