In C#, what happens when you call an extension method on a null object?
That will work fine (no exception). Extension methods don’t use virtual calls (i.e. it uses the “call” il instruction, not “callvirt”) so there is no null check unless you write it yourself in the extension method. This is actually useful in a few cases: public static bool IsNullOrEmpty(this string value) { return string.IsNullOrEmpty(value); } public … Read more