C# Byte CompareTo(Byte)

Description

Byte CompareTo(Byte) compares this instance to a specified 8-bit unsigned integer and returns an indication of their relative values.

Syntax

Byte.CompareTo(Byte) has the following syntax.


public int CompareTo(
  byte value
)

Parameters

Byte.CompareTo(Byte) has the following parameters.

  • value - An 8-bit unsigned integer to compare.

Returns

Byte.CompareTo(Byte) method returns A signed integer that indicates the relative order of this instance and value. Return Value Description 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.

Example

The following code example demonstrates generic and non-generic versions of the CompareTo method for several value and reference types.


// w  w w .ja v  a  2s.  co  m
using System;

public class Sample 
{
    public static void Main() 
    {
        Byte     b1 = 1,     b2 = 1;
        int result = b1.CompareTo(b2);
        System.Console.WriteLine(result);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version