One of the rules for implementing the Dispose
method says:
Throw an
ObjectDisposedException
from instance methods on this type (other thanDispose
) when resources are already disposed. This rule does not apply to theDispose
method because it should be callable multiple times without throwing an exception.
See: http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx
Does this mean that if I want to implement properties correctly, I cannot use auto-implemented properties? Do I need properties that implement it like this one?
private bool _property;
public bool Property
{
get
{
if(disposed) throw new ObjectDisposedException("MyClass");
return _property;
}
set
{
if(disposed) throw new ObjectDisposedException("MyClass");
_property=value;
}
}