ThrowIfNotEqual Method
Definition
ThrowIfNotEqual<T>(T, T, string, IEqualityComparer<T>, string)
Validates and throws an ArgumentOutOfRangeException if the specified x object are not equal to the y object.
public static void ThrowIfNotEqual<T>(T x, T y, string paramName, IEqualityComparer<T> comparer = null, string message = null)
Parameters
xTThe first object to compare.
yTThe second object to compare.
paramNamestringThe name of the parameter that caused the exception.
comparerIEqualityComparer<T>The IEqualityComparer<T> implementation to use when comparing
xandy.messagestringA message that describes the error.
Type Parameters
TThe type of objects to compare.
Exceptions
- ArgumentOutOfRangeException
xandyare not equal to one another.