private void test()
{
string tst = null;
try
{
tst = "abc";
}
catch (Exception)
{
throw;
}
finally
{
tst = null;
}
}
My query is – Is it meaningful to type tst = null; in the finally block as the string class doesn’t have the disposable method ?
Even if
stringimplementedIDisposable, setting a variable to null wouldn’t call theDisposemethod. It’s utterly pointless, as is the catch block with the throw.If you see code like this in a codebase you’re maintaining, rip it out and have a quiet word with whoever put it in there in the first place.