Say we have
void Foo() {
var bar = new Bar();
bar.Woo();
}
Will the CLR use the stack for the local variable?
If not, why? Is it not more efficient to use the stack for variables which have a limited scope instead of using a more expensive garbage collector?
Not only the CLR would need to know that the scope is local, but also that the object wont be referenced from anywhere else. This would need a deep code analysis except for the most trivial cases, like the one you posted.