"Attempt to return reference to stack var"

static ref int DoSomethingBad() {
	var x = 123;
	return ref x; // Can't do this because 'x' only exists on the current method's stack. Once we return from this method, it no longer exists. Dereferencing the returned value would be an undefined behaviour.
}


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