2009-01-26 8 views

Respuesta

1

Además de ArgumentException también hay ArgumentNullException y ArgumentOutOfRangeException.

Resumen breve;

  • System.ArgumentException - excepción general,
  • System.ArgumentNullException - valor inesperado null,
  • System.ArgumentOutOfRangeException - valor inesperado.

uso estándar:

void GetEntity(string currentName) 
{ 
    if (String.IsNullOrEmpty(currentName)) 
    { 
    throw new ArgumentNullException(nameof(currentName)); 
    } 

    //... 
} 

PS. NotSupportedException también es útil (por ejemplo, cuando el conjunto de argumentos obligaría al método a realizar un escenario no admitido).

Cuestiones relacionadas