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

What does this code print, and why is calling an extension method on a null reference not necessarily a NullReferenceException?

static class Ext { public static bool IsEmpty(this string s) => s == null || s.Length == 0; } string name = null; Console.WriteLine(name.IsEmpty());