Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC#nullable reference typesSingle-choice MCQ

Why does the generic method below warn even though T is constrained-free, and what attribute fixes the intent?

public T GetOrDefault<T>(T value) { return value is null ? default : value; // warning on 'default' }