I have code that basically looks like this (it isn't actually object, but rather a custom class):
object thing
try {
thing = new object();
......
} catch { stuff }
finally {
if (thing != null) { some clean up code }
But VS is not letting me do this because it says I am referencing an unassigned variable. I am well aware it could be unassigned when this code is run, which is why the null check is there. I don't want to instantiate the object outside of the try block because it does a fair bit and could throw an exception, and I would prefer against wrapping the whole thing in another try/catch block just so I can instantiate it up there. Is there something else I can do?