"Scoped local example"

static void Test() {
	var x = 123;
	scoped var wrapper = new IntRefWrapper(); // We force 'wrapper' to be scoped to the current method even though the expression 'new IntRefWrapper()' would normally set it to calling method
	wrapper.IntRef = ref x; // This wouldn't be permitted without the scoped modifier above
	PrintRefVal(wrapper);
}

static void PrintRefVal(IntRefWrapper w) => Console.WriteLine(w.IntRef);


Code snippet taken from "Complete C# Quick Reference - C# 11".