To Throw or Not to Throw
- by serhio
// To Throw
void PrintType(object obj)
{
if(obj == null)
{
throw new ArgumentNullException("obj")
}
Console.WriteLine(obj.GetType().Name);
}
// Not to Throw
void PrintType(object obj)
{
if(obj != null)
{
Console.WriteLine(obj.GetType().Name);
}
}
What principle to keep? Personally
Personally I prefer the first one its say developer-friendly.
The second one its say user-friendly.
What do you think?