[]
Compares the current Length instance to a specified object and returns an indication of their relative values.
public int CompareTo(object obj)
Type | Name | Description |
---|---|---|
object | obj | An object to compare with the current instance. |
Type | Description |
---|---|
int | An int value indicating the relative order of the objects being compared. |
var length1 = new Length("10in");
var length2 = new Length("5in");
int comparison = length1.CompareTo(length2); // 1
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(Length other)
Type | Name | Description |
---|---|---|
Length | other | An object to compare with this instance. |
Type | Description | ||||||
---|---|---|---|---|---|---|---|
int | An int value indicating the relative order of the objects being compared.
|
var length1 = new Length("1in");
var length2 = new Length("2in");
int result = length1.CompareTo(length2); // -1