System.Data.SqlTypes.SqlString.CompareTo C# (CSharp) Method

CompareTo() public method

public CompareTo ( SqlString value ) : int
value SqlString
return int
        public int CompareTo(SqlString value)
        {
            // If both Null, consider them equal.
            // Otherwise, Null is less than anything.
            if (IsNull)
                return value.IsNull ? 0 : -1;
            else if (value.IsNull)
                return 1;

            int returnValue = StringCompare(this, value);

            // Conver the result into -1, 0, or 1 as this method never returned any other values
            //  This is to ensure the backcompat
            if (returnValue < 0)
            {
                return -1;
            }
            if (returnValue > 0)
            {
                return 1;
            }

            return 0;
        }

Same methods

SqlString::CompareTo ( object value ) : int

Usage Example

Example #1
0
        /**
         * Compares two instances of SqlString to determine if the first is less than the second.
         * @param x A SqlString instance
         * @param y A SqlString instance
         * @return A SqlBoolean that is True if the first instance is less than the second instance, otherwise False.
         * If either instance of SqlString is null, the Value of the SqlBoolean will be Null.
         */
        public static SqlBoolean LessThanOrEqual(SqlString x, SqlString y)
        {
            if (x.IsNull || y.IsNull)
            {
                return(SqlBoolean.Null);
            }

            if (x.CompareTo(y) <= 0)
            {
                return(SqlBoolean.True);
            }

            return(SqlBoolean.False);
        }
All Usage Examples Of System.Data.SqlTypes.SqlString::CompareTo