No. You should never throw a NullReferenceException
manually. It should only ever be thrown by the framework itself.
In this context, you should be throwing ArgumentNullException
for both instance
and culture
:
static public String ToTitleCase(this string instance, CultureInfo culture)
{
if (instance == null)
throw new ArgumentNullException("instance");
if (culture == null)
throw new ArgumentNullException("culture");
return culture.TextInfo.ToTitleCase(instance);
}
From the NullReferenceException documentation:
Note that applications throw the
ArgumentNullException
exception
rather than the
NullReferenceException
exception
discussed here.