Show / Hide Table of Contents

Class GlobalStructExtensions

Extension methods for all structs.
Inheritance
System.Object
GlobalStructExtensions
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.Global
Assembly: Annex.dll
Syntax
[PublicAPI]
public static class GlobalStructExtensions

Methods

| Improve this Doc View Source

NullIf<T>(T, T)

Returns null if the source value is equal to the provided value.
Declaration
public static T? NullIf<T>(this T this, T value)
    where T : struct
Parameters
Type Name Description
T this The source value.
T value The value to compare.
Returns
Type Description
System.Nullable<T> null if the source value is equal to the provided value, otherwise false.
Type Parameters
Name Description
T The type of the value.
Examples
10.NullIf(10); // null
5.NullIf(10); // 5
| Improve this Doc View Source

NullIf<T>(T, T, IEqualityComparer<T>)

Returns null if the source value is equal to the provided value.
Declaration
public static T? NullIf<T>(this T this, T value, [NotNull] IEqualityComparer<T> comparer)
    where T : struct
Parameters
Type Name Description
T this The source value.
T value The value to compare.
System.Collections.Generic.IEqualityComparer<T> comparer The comparer implementation to use to check for equality.
Returns
Type Description
System.Nullable<T> null if the source value equals the provided value, otherwise false.
Type Parameters
Name Description
T The type of the value.
Examples
10.NullIf(10, EqualityComparer<T>.Default); // null
5.NullIf(10, EqualityComparer<T>.Default); // 5
Exceptions
Type Condition
System.ArgumentNullException comparer is null.
| Improve this Doc View Source

NullIfDefault<T>(T)

Returns null if the source value equals the default value for the type.
Declaration
public static T? NullIfDefault<T>(this T this)
    where T : struct
Parameters
Type Name Description
T this The source value.
Returns
Type Description
System.Nullable<T> null if the source value equals the default value for the type, otherwise false.
Type Parameters
Name Description
T The type of the source value.
Examples
default(int).NullIfDefault(); // null
10.NullIfDefault(); // 10
  • Improve this Doc
  • View Source
Back to top Copyright © George Taylor Buchanan
Generated by DocFX