This is a made up example to demonstrate my question better. I've been using this Entity class for a while now so that my entity classes can be make use of "using" blocks. But to be honest I don't know what should go in the Dispose(bool disposing) method. This code all works fine but like I said, I'm not sure what to use the method for.
Thanks
void Main()
{
using (Person p = new Person())
{
p.First="Stan";
p.Last="Smith";
SayHello(p);
}
}
public abstract class Entity : IDisposable
{
public virtual void Dispose(bool disposing)
{
if (disposing)
{
// Add logic here for common dispose.
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
public class Person : Entity
{
public string First { get; set; }
public string Last { get; set; }
}
public void SayHello(Person p)
{
Console.WriteLine(@"Hello {0} {1}", p.First, p.Last);
}