I have seen developers have try, catch and finally in almost all the methods they write and they nullify the objects which they've created in the Finally block.
Eg-
public void Demo()
{
Something s = null;
try
{
s = new Something();
}
catch (Exception ex)
{
throw;
}
finally
{
s = null;
}
}
Is there any use of doing this? The propose of this is to nullify the object so GC can collect them.
Without doing this, Can we use a "using" or IDisposable instead?
What is the best practice?