I'm working on a method that does something given a string parameter. A valid value for the string parameter is anything other than null or string.Empty. So my code looks like this.
private void SomeMethod(string someArgument)
{
if(string.IsNullOrEmpty(someArgument))
throw new ArgumentNullException("someArgument");
// do some work
}
Nothing too exciting there. My question is, is it okay to throw an ArgumentNullException even if the string is equal to string.Empty? Because technically it isn't null. If you believe it should not throw ArgumentNullException, what exception should be thrown?
See Question&Answers more detail:os