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

What does this method do at the IL/runtime level, and why does it compile successfully?

static ref int FirstElem(int[] arr) => ref arr[0]; // usage var a = new[] { 1, 2, 3 }; ref int r = ref FirstElem(a); r = 100; // a[0] is now 100