C# | Byte.CompareTo(Byte) Method Last Updated : 07 Dec, 2021 Comments Improve Suggest changes Like Article Like Report This method is used to compare this instance to a specified 8-bit unsigned integer and returns an indication of their relative values.Syntax: 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:Example 1: CSHARP // C# program to demonstrate // Byte.CompareTo(byte) // Method using System; class GFG { // Main Method public static void Main() { // Declaring val1 and val2 byte val1, val2; // initializing the val1, // val2 and val3 val1 = 12; val2 = 13; // getting compared constant // using CompareTo method int i = val2.CompareTo(val1); // checking the condition if (i > 0) Console.Write("val2 is greater than val1"); else if (i < 0) Console.Write("val2 is less than val1"); else Console.Write("val1 is equal to val1"); } } Output: val2 is greater than val1 Example 2: CSHARP // C# program to demonstrate // Byte.CompareTo(byte) // Method using System; class GFG { // Main Method public static void Main() { // checking the condition // calling check() method check((byte)10, (byte)20); check((byte)30, (byte)20); check((byte)10, (byte)10); check((byte)5, (byte)7); check((byte)40, (byte)50); check((byte)1, (byte)2); } // Defining the check method public static void check(byte v1, byte v2) { // getting compared constant // using CompareTo() method int i = v1.CompareTo(v2); // checking the condition if (i > 0) Console.WriteLine(v1 + " is greater than " + v2); else if (i < 0) Console.WriteLine(v1 + " is less than " + v2); else Console.WriteLine(v1 + " is equal to " + v2); } } Output: 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 Reference: https://docs.microsoft.com/en-us/dotnet/api/system.byte.compareto?view=netframework-4.7.2#System_Byte_CompareTo_System_Byte_ Comment More infoAdvertise with us Next Article C# | Byte.CompareTo(Byte) Method rohitprasad3 Follow Improve Article Tags : C# CSharp-Byte-Struct CSharp-method Similar Reads C# | Byte.CompareTo(Object) Method This method is used to compare the current instance to a specified object and returns a sign of their relative values. Regardless of value, any instance of Byte will be considered greater than null. Syntax: public int CompareTo (object value); Here, it takes an object to compare, or null. Return Val 2 min read C# | Boolean.CompareTo(Boolean) Method Boolean.CompareTo(Boolean) Method is used to compare the current instance to a specified Boolean object and returns an indication of their relative values. Syntax: public int CompareTo (bool value); Here, the value is a Boolean object to compare to the current instance. Return Value: This method ret 1 min read C# | Byte.Equals(Byte) Method This method is used to return a value indicating whether this instance and a specified Byte object represent the same value. Syntax: public bool Equals (byte obj); Here, obj is a byte object to compare to this instance. Return Value: This method returns true if obj is equal to this instance otherwis 2 min read C# | Char.CompareTo() Method In C#, Char.CompareTo() is a System.Char struct method which is used to compare this instance of a specified object or value type and check whether the given instance is precedes, follow, or appears in the same position in the sort order as the specified object or value type. This method can be over 3 min read C# | Boolean.CompareTo(Object) Method Boolean.CompareTo(Object) Method is used to compare the current instance to a specified object and returns an integer which shows their relationship to one another. Syntax: public int CompareTo (object obj); Here, it takes an object to compare to current instance or null. Return Value: This method r 2 min read Int16.CompareTo() Method in C# Int16.CompareTo Method is used to compare the current instance to a specified object or another Int16 instance. It returns an integer which shows whether the value of the current instance is less than, equal to, or greater than the value of the specified object or the other Int16 instance. There are 4 min read C# | Byte.GetTypeCode() Method This method is used to return the TypeCode for value type Byte. Syntax: public TypeCode GetTypeCode (); Return Value: It returns the enumerated constant, Byte.Below programs illustrate the use of Byte.GetTypeCode() Method:Example 1: CSharp // C# program to demonstrate // Byte.GetTypeCode() Method us 2 min read Decimal.CompareTo() Method in C# This method is used to compare the current instance to a specified object or Decimal and returns an indication of their relative values. There are 2 methods in the overload list of this method as follows: CompareTo(Decimal) MethodCompareTo(Object) MethodDecimal.CompareTo(Decimal) Method This method 4 min read C# String CompareOrdinal() Method In C#, CompareOrdinal() is a method of the String class. This method is used to compare the two specified string objects or substrings using the numerical values (Unicode) of the corresponding Char objects in each string or substring. It performs a case-sensitive and culture-insensitive comparison.O 4 min read Decimal.Compare() Method in C# This method is used to compare two specified Decimal values. Syntax: public static int Compare (decimal a1, decimal a2); Parameters: a1:This parameter specifies the first value to compare. a2:This parameter specifies the second value to compare. Return Value: It returns a signed number indicating th 2 min read Like