Method CompareTo
CompareTo(FieldValue)
Compares this instance to the specified FieldValue
instance and returns and returns an integer that indicates
whether this instance is less than, the same as, or greater than
the specified FieldValue instance.
Declaration
public int CompareTo(FieldValue other)
Parameters
Type | Name | Description |
---|---|---|
FieldValue | other | The value to compare with this instance. |
Returns
Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
Int32 | An integer indicating whether this value is less than,
same as or greater than other .
|
Remarks
The comparison semantics roughly follows the one described in
section Value Comparison Operators in the SQL Reference
Guide. The following comparisons are allowed:
-
A numeric FieldValue instance is comparable with any
other numeric FieldValue instance. When comparing
numeric instances of different types, the value of the "smaller"
type is converted to the value of the "larger" type in the rough
order of
int
,long
,double
,decimal
(although comparison ofdouble
anddecimal
values is treated specially given thatdecimal
has higher precision but smaller range thandouble
). -
A StringValue instance is comparable to another
StringValue instance. The strings are compared
using Ordinal mode as in
string.Compare(value1, value2, StringComparison.Ordinal)
. - A BooleanValue instance is comparable to another BooleanValue instance with values being compared via CompareTo(Boolean).
- A TimestampValue instance is comparable to another TimestampValue instance with values being compared via CompareTo(DateTime).
Exceptions
Type | Condition |
---|---|
ArgumentNullException | other
is null . |
NotSupportedException | Comparison between this
instance and other is not supported.
|