Suppose I have a class named `ABC'
Class ABC:IDisposable
{
public string name {get;set;}
public string Method1()
{
// Implements
}
//end of class
}
I hear from other's that you should use always inherit IDisposable
to free memory creating object of above class like this:
using(ABC objABC = new ABC())
{
objABC.Method1();
}
but there is other ways to call and use above class and methods for E.g.
private string testmethods()
{
ABC objABC = new ABC();
string test = objABC.Method1();
// I want to know this above `objABC` 's memory is free after finish `testmethods()`?
// we can also call using this like below
string test2 = new ABC().Method1();
}
I want to know which is the best way to achieve this?
I also want to know is, is that Object memory automatically cleared after end of testmethods()
calls ?