I fail to see how this is advantageous to throwing ArgumentNullException
. As the matter of fact, I'd rather do this:
public void Foo(MyClass item, MyClass2 item2)
{
if (item == null)
throw new ArgumentNullException("item");
if (item2 == null)
throw new ArgumentNullException("item2");
}
This way I let the programmer know which parameter was bad. With NotNullable<T>
I imagine it would look like this:
public void Foo(NotNullable<MyClass> item, NotNullable<MyClass> item2) { ... }
Foo((NotNullable<MyClass>)myVar1, (NotNullable<MyClass2>)myVar2);
Now I get "Value is not initialized."
thrown in my face. Which one?