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

Which of these `ref`-returning members is rejected by the C# compiler's ref-safety (escape) analysis?

ref int A(int[] arr) => ref arr[0]; // candidate ref int B(MyStruct s) => ref s.Field; // candidate ref int C(ref MyStruct s) => ref s.Field; // candidate struct MyStruct { public int Field; }