// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT License. // See the LICENSE file in the project root for more information. namespace System.Reactive { /// /// Represents a type with a single value. This type is often used to denote the successful completion of a void-returning method (C#) or a Sub procedure (Visual Basic). /// [Serializable] public readonly struct Unit : IEquatable { /// /// Determines whether the specified value is equal to the current . Because has a single value, this always returns true. /// /// An object to compare to the current value. /// Because has a single value, this always returns true. public bool Equals(Unit other) => true; /// /// Determines whether the specified System.Object is equal to the current . /// /// The System.Object to compare with the current . /// true if the specified System.Object is a value; otherwise, false. public override bool Equals(object? obj) => obj is Unit; /// /// Returns the hash code for the current value. /// /// A hash code for the current value. public override int GetHashCode() => 0; /// /// Returns a string representation of the current value. /// /// String representation of the current value. public override string ToString() => "()"; /// /// Determines whether the two specified values are equal. Because has a single value, this always returns true. /// /// The first value to compare. /// The second value to compare. /// Because has a single value, this always returns true. [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "first", Justification = "Parameter required for operator overloading."), Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "second", Justification = "Parameter required for operator overloading.")] public static bool operator ==(Unit first, Unit second) => true; /// /// Determines whether the two specified values are not equal. Because has a single value, this always returns false. /// /// The first value to compare. /// The second value to compare. /// Because has a single value, this always returns false. [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "first", Justification = "Parameter required for operator overloading."), Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "second", Justification = "Parameter required for operator overloading.")] public static bool operator !=(Unit first, Unit second) => false; /// /// Gets the single value. /// public static Unit Default => default; } }