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
- Difference between Method Overriding and Method Hiding in C#
- Main Method in C#
- Stack.Pop() Method in C#
- C# | Math.Max() Method
- DateTime.Add() Method in C#
- C# | Math.Abs() Method | Set - 2
- C# | Math.Abs() Method | Set - 1
- C# | Method Parameters
- C# | Math.Log() Method
- C# | Method Overriding
- C# | IsNullOrEmpty() Method
- C# | Math.Min() Method
- Stack.Contains() Method in C#
- Queue.Contains() Method in C#
- C# | String.Contains() Method
- C# | Math.Sin() Method
- C# | Math.Cos() Method
- C# | Math.Tan() Method
- C# | CompareOrdinal() Method
- C# | Trim() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.