Resolving null values in C#
August 24, 2017 1 Comment
Say you have a method which accepts a string parameter. The method may need to handle null values in some way. One strategy is to validate the parameter and throw an exception:
private static string Resolve(string input) { if (input == null) throw new ArgumentNullException("Input"); . . . }
Another strategy is to provide some default value with an if-else statement: