I was wondering if using curly brackets to define scopes within a method call would 'force' or give a information to the C# Garbage collector to release the memory allocated within that block, so, let's take the piece of code below as an example:
void MyMethod() {
//here some important code, like reading some information from disk, api, whatever.
//Open brackets to define scope...
{
var myClassObject = new MyClass();
myClassObject.DoSomething();
var mySecondClassObject = new MySecondClass();
mySecondClassObject.DoSomething();
}
//I expect that at this moment, GC would release myClassObject and MySecondClassObject from the Heap...
//is that correct?
//here do something else
/...
}