Which of the following approach makes sense to adopt, throw ObjectDisposedException
before or after checking the method parameters?
private bool IsDisposed { get; set; }
public void DoSomething1(int value)
{
if (IsDisposed)
{
throw new ObjectDisposedException(null);
}
if (value <= 0)
throw new ArgumentOutOfRangeException(nameof(value));
}
public void DoSomething2(int value)
{
if (value <= 0)
throw new ArgumentOutOfRangeException(nameof(value));
if (IsDisposed)
{
throw new ObjectDisposedException(null);
}
}
Aucun commentaire:
Enregistrer un commentaire