1

Closed

SqlAzManSID == and != Operators

description

Andrea,
Thanks for implementing SqlAzManSID Equals functions. Can you also implement == and != operators? I still get hit by calling them because they only do reference comparision. If you'd like to implement them, please pay attention to null objects.
 
Thanks!
 
Richard.
Closed Jun 21, 2010 at 12:17 PM by aferende

comments

aferende wrote Jun 21, 2010 at 12:16 PM

/// <summary>
    /// Implements the operator ==.
    /// </summary>
    /// <param name="sid1">The sid1.</param>
    /// <param name="sid2">The sid2.</param>
    /// <returns>The result of the operator.</returns>
    public static bool operator ==(SqlAzManSID sid1, SqlAzManSID sid2)
    {
        return sid1.Equals(sid2.BinaryValue);
    }

    /// <summary>
    /// Implements the operator !=.
    /// </summary>
    /// <param name="sid1">The sid1.</param>
    /// <param name="sid2">The sid2.</param>
    /// <returns>The result of the operator.</returns>
    public static bool operator !=(SqlAzManSID sid1, SqlAzManSID sid2)
    {
        return !(sid1.Equals(sid2.BinaryValue));
    }

wrote Jun 21, 2010 at 12:17 PM

Resolved with changeset 49565.

tangrl wrote Jun 21, 2010 at 3:01 PM

Andrea,
You may want to consider the case when sid1==null.