public void RetireHenchman()
{
var disposableMinion = Minion as IDisposable;
if (disposableMinion != null)
disposableMinion.Dispose();
Minion = null;
}
The null coalescing operator can make this code more concise as well:
public void RetireHenchman()
{
(Minion as IDisposable)?.Dispose();
Minion = null;
}
No comments:
Post a Comment