Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC#extension methodsSingle-choice MCQ

Why can you call an extension method on a null reference without an immediate NullReferenceException?

public static class StrExt { public static bool IsEmpty(this string s) => s == null || s.Length == 0; } // ... string s = null; bool e = s.IsEmpty(); // does this throw?