Ensure

Provides methods for ensuring that method arguments meet specific criteria. This class provides a consistent way to validate arguments and throw appropriate exceptions.

Syntax

public static class Ensure

Inheritance

Methods

ArgumentNotNull

public static void ArgumentNotNull(object argument, string argumentName)
Ensures that the specified argument is not null.

Parameters

  • argument object: The argument to validate.
  • argumentName string: The name of the argument being validated.

Exceptions

  • [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception): Thrown when argument is null.

ArgumentNotNullOrWhiteSpace

public static void ArgumentNotNullOrWhiteSpace(string argument, string argumentName)
Ensures that the specified argument is not null or whitespace.

Parameters

  • argument string: The argument to validate.
  • argumentName string: The name of the argument being validated.

Exceptions

  • [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception): Thrown when argument is null or whitespace.