An ArgumentNullException is sometimes used in the .NET Framework for the case of String.IsNullOrEmpty - an example of System.Windows.Forms.Clipboard.SetText .
Therefore, I think it is wise to do the same in your code, unless there is some real value to distinguish between the two cases.
Please note that these and other exceptions derived from an ArgumentException typically indicate a programming error and, therefore, you must provide the information necessary to help the developer diagnose the problem. Personally, I find it unlikely that the developer will find this confusing if you use ArgumentNullException for an empty string argument, especially if you document this behavior, as in the example below.
/// <summary> /// ... description of method ... /// </summary> /// <param name="someArgument">... description ...</param> /// <exception cref="ArgumentNullException">someArgument is a null reference or Empty.</exception> public void SomeMethod(string someArgument) { ... }
Joe Aug 31 '09 at 5:57 2009-08-31 05:57
source share