Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC#ref struct and ref returnsSingle-choice MCQ

Why does the compiler reject returning `ref local` here, and what runtime safety rule (ref safety / escape analysis) is being enforced?

static ref int Bad() { int x = 42; return ref x; // compile error }