Search Results for

    Show / Hide Table of Contents

    Class Argument

    Useful routines for checking arguments of a function for correctness.

    Inheritance
    Object
    Argument
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Microsoft.ML.Probabilistic.Utilities
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    public static class Argument

    Methods

    CheckIfInRange(Boolean, String, String)

    Throws an ArgumentOutOfRangeException if the inRangeCondition is false.

    Declaration
    public static void CheckIfInRange(bool inRangeCondition, string argumentName, string message)
    Parameters
    Type Name Description
    Boolean inRangeCondition

    true if the argument is in its valid range, false otherwise.

    String argumentName

    The name of the argument.

    String message

    The exception message.

    CheckIfNotNull<T>(T, String)

    Throws an ArgumentNullException if the argument is null.

    Declaration
    public static void CheckIfNotNull<T>(T argument, string argumentName)
    Parameters
    Type Name Description
    T argument

    The argument.

    String argumentName

    The name of the argument.

    Type Parameters
    Name Description
    T

    The type of the argument.

    Remarks

    There is no "class" restriction on T because in generic code it may be convinient to pass value types into CheckIfNotNull<T>(T, String). Even if it is a no-op for them.

    CheckIfNotNull<T>(T, String, String)

    Throws an ArgumentNullException with the specified message if the argument is null.

    Declaration
    public static void CheckIfNotNull<T>(T argument, string argumentName, string message)
    Parameters
    Type Name Description
    T argument

    The argument.

    String argumentName

    The name of the argument.

    String message

    The exception message.

    Type Parameters
    Name Description
    T

    The type of the argument.

    Remarks

    There is no "class" restriction on T because in generic code it may be convinient to pass value types into CheckIfNotNull<T>(T, String, String). Even if it is a no-op for them.

    CheckIfValid(Boolean, String)

    Throws an ArgumentException without specifying the argument if the isValidCondition is false.

    Declaration
    public static void CheckIfValid(bool isValidCondition, string message)
    Parameters
    Type Name Description
    Boolean isValidCondition

    true if the exception should not be thrown, false otherwise.

    String message

    The exception message.

    CheckIfValid(Boolean, String, String)

    Throws an ArgumentException if the isValidCondition is false.

    Declaration
    public static void CheckIfValid(bool isValidCondition, string argumentName, string message)
    Parameters
    Type Name Description
    Boolean isValidCondition

    true if the argument has a valid value, false otherwise.

    String argumentName

    The name of the argument.

    String message

    The exception message.

    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.