If I define an extension method, for example:
static public String ToTitleCase(this string instance, CultureInfo culture)
{
if (instance == null)
throw new NullReferenceException();
if (culture == null)
throw new ArgumentNullException("culture");
return culture.TextInfo.ToTitleCase(instance);
}
Do I need to check the string instance for null and throw a null reference exception on my own? Or does the CLR handle extension methods, such as instance methods in this case, and handle check / throw for me?
I know extension methods are just syntactic sugar for static methods, maybe the C # compiler adds to the check at compile time? Please clarify:)
source
share