This method is used to compare this instance to a specified 8-bit unsigned integer and returns an indication of their relative values.
public int CompareTo (byte value);
Here, the value is an 8-bit unsigned integer to compare.
Return Value: This method returns a signed integer that indicates the relative order of this instance and value.
- Less than zero: This instance is less than value.
- Zero: This instance is equal to value.
- Greater than zero: This instance is greater than value.
Below programs illustrate the use of Byte.CompareTo(Byte) Method:
val2 is greater than val1
10 is less than 20 30 is greater than 20 10 is equal to 10 5 is less than 7 40 is less than 50 1 is less than 2