I have a code like below where from one method I get a object (just copy from global object without new) and do the operation. I do dispose global object while closing a child form. However, at method level I don't dispose local object. Is this required to dispose/set null to local object as well? What should be the best practice for such scenario.
Please note this object has reference of "Axshockwaveflashplayer" object that's why i am little bit worried about local object as well.
class Test
{
Method()
{
var obj = GetContainerObject() //copying object
var proxy = obj as ExternalIntClass //copying object
proxy.call("Name", param);
**//After use should i dispose obj and proxy local objects ?**
}
private object GetContainerObject()
{
switch(condition)
case 1 :
return proxy1;
case 2:
return proxy2;
}
Dispose()
{
proxy1 = null;
proxy2 = null;
}
}