Show / Hide Table of Contents

Class GlobalBooleanExtensions

Global extension methods for System.Boolean.
Inheritance
System.Object
GlobalBooleanExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Annex.Booleans.Global
Assembly: Annex.dll
Syntax
[PublicAPI]
public static class GlobalBooleanExtensions

Methods

| Improve this Doc View Source

In<TValue, TComparand>(TValue, TComparand[])

Determines if the value is contained in the sequence of specified comparands. For constant comparands, consider using a static readonly System.Collections.Generic.HashSet`1 instead.
Declaration
public static bool In<TValue, TComparand>([NotNull] this TValue this, [NotNull] params TComparand[] comparands)
    where TValue : TComparand
Parameters
Type Name Description
TValue this The source value.
TComparand[] comparands The comparands to compare the value to.
Returns
Type Description
System.Boolean true if the value is contained in the list of specified comparands, otherwise false.
Type Parameters
Name Description
TValue The type of the value.
TComparand The type of the comparands.
Remarks
Elements are compared to the specified value by using the default equality comparer, System.Collections.Generic.EqualityComparer`1.Default.

For constant comparands, consider using a static readonly System.Collections.Generic.HashSet`1 instead to avoid initializing a new array every time the method is called.
Examples
int num = 0, possibleNum1 = 1, possibleNum2 = 5; // Preferably not constant values

num.In(possibleNum1, possibleNum2); // false
Exceptions
Type Condition
System.ArgumentNullException this or comparands is null.
See Also
System.Collections.Generic.HashSet`1.Contains(`0)
| Improve this Doc View Source

In<TValue, TComparand>(TValue, IEqualityComparer<TComparand>, TComparand[])

Determines if the value is contained in the sequence of specified comparands using the specified System.Collections.Generic.IEqualityComparer<T>. For constant comparands, consider using a static readonly System.Collections.Generic.HashSet`1 instead.
Declaration
public static bool In<TValue, TComparand>([NotNull] this TValue this, [NotNull] IEqualityComparer<TComparand> comparer, [NotNull] params TComparand[] comparands)
    where TValue : TComparand
Parameters
Type Name Description
TValue this The value to check.
System.Collections.Generic.IEqualityComparer<TComparand> comparer The equality comparer implementation to use when comparing values.
TComparand[] comparands The comparands to compare the value to.
Returns
Type Description
System.Boolean true if the value is contained in the list of specified comparands, otherwise false.
Type Parameters
Name Description
TValue The type of the value.
TComparand The type of the comparands.
Remarks
For constant comparands, consider using a static readonly System.Collections.Generic.HashSet`1 instead to avoid initializing a new array every time the method is called.
Examples
int num = 0, possibleNum1 = 1, possibleNum2 = 5; // Preferably not constant values

num.In(possibleNum1, possibleNum2, EqualityComparer<int>.Default); // false
Exceptions
Type Condition
System.ArgumentNullException this, comparer, or comparands is null.
See Also
System.Collections.Generic.HashSet`1.Contains(`0)
| Improve this Doc View Source

InRange<T>(T, T, T)

Determines if the value is within the specified range. Defaults to Include.
Declaration
public static bool InRange<T>([NotNull] this T this, [NotNull] T bound1, [NotNull] T bound2)
Parameters
Type Name Description
T this The source value.
T bound1 The first bound for the range.
T bound2 The second bound for the range.
Returns
Type Description
System.Boolean true if the value is within bounds, otherwise false.
Type Parameters
Name Description
T The type of the value.
Examples
10.InRange(1, 10); // true
10.InRange(1, 5); // false
10.InRange(20, 5); // true
Exceptions
Type Condition
System.ArgumentNullException this, bound1, or bound2 is null.
| Improve this Doc View Source

InRange<T>(T, T, T, BoundType)

Determines if the value is within the specified range.
Declaration
public static bool InRange<T>([NotNull] this T this, [NotNull] T bound1, [NotNull] T bound2, BoundType boundType)
Parameters
Type Name Description
T this The source value.
T bound1 The first bound for the range.
T bound2 The second bound for the range.
BoundType boundType The type of range bounds.
Returns
Type Description
System.Boolean true if the value is within bounds, otherwise false.
Type Parameters
Name Description
T The type of the value.
Examples
10.InRange(1, 10, BoundType.ExcludeInclude); // true
10.InRange(10, 1, BoundType.ExcludeInclude); // true
10.InRange(10, 1, BoundType.IncludeExclude); // false
10.InRange(1, 10, BoundType.Exclude); // false
Exceptions
Type Condition
System.ArgumentNullException this, bound1, or bound2 is null.
System.ArgumentOutOfRangeException boundType is invalid.
| Improve this Doc View Source

InRange<T>(T, T, T, BoundType, IComparer<T>)

Determines if the value is within the specified range.
Declaration
public static bool InRange<T>([NotNull] this T this, [NotNull] T bound1, [NotNull] T bound2, BoundType boundType, [NotNull] IComparer<T> comparer)
Parameters
Type Name Description
T this The source value.
T bound1 The first bound for the range.
T bound2 The second bound for the range.
BoundType boundType The type of range bounds.
System.Collections.Generic.IComparer<T> comparer The comparer implementation to use when comparing values.
Returns
Type Description
System.Boolean true if the value is within bounds, otherwise false.
Type Parameters
Name Description
T The type of the value.
Examples
10.InRange(1, 10, BoundType.Include, Comparer<T>.Default); // true
Exceptions
Type Condition
System.ArgumentNullException this, bound1, bound2, or comparer is null.
System.ArgumentOutOfRangeException boundType is invalid.
| Improve this Doc View Source

InRange<T>(T, T, T, IComparer<T>)

Determines if the value is within the specified range. Defaults to Include.
Declaration
public static bool InRange<T>([NotNull] this T this, [NotNull] T bound1, [NotNull] T bound2, [NotNull] IComparer<T> comparer)
Parameters
Type Name Description
T this The source value.
T bound1 The first bound for the range.
T bound2 The second bound for the range.
System.Collections.Generic.IComparer<T> comparer The comparer implementation to use when comparing values.
Returns
Type Description
System.Boolean true if the value is within bounds, otherwise false.
Type Parameters
Name Description
T The type of the value.
Examples
10.InRange(1, 10, Comparer<T>.Default); // true
Exceptions
Type Condition
System.ArgumentNullException this, bound1, bound2, or comparer is null.
  • Improve this Doc
  • View Source
Back to top Copyright © George Taylor Buchanan
Generated by DocFX