C# Byte Equals(Byte)

Description

Byte Equals(Byte) returns a value indicating whether this instance and a specified Byte object represent the same value.

Syntax

Byte.Equals(Byte) has the following syntax.


public bool Equals(
  byte obj
)

Parameters

Byte.Equals(Byte) has the following parameters.

  • obj - An object to compare to this instance.

Returns

Byte.Equals(Byte) method returns true if obj is equal to this instance; otherwise, false.

Example

The following code example determines whether the first Byte value is equal to the second Byte value, and whether the first Byte value is equal to the boxed version of the second Byte value.


//ww  w .j  a  v  a2 s.c om

using System;

class Sample 
{
    public static void Main() 
    {
    byte   byteVal1 = 0x7f;
    byte   byteVal2 = 122;
    object objectVal3 = byteVal2;

    Console.WriteLine("byteVal1 = {0}, byteVal2 = {1}, objectVal3 = {2}\n",
                       byteVal1, byteVal2, objectVal3);
    Console.WriteLine("byteVal1 equals byteVal2?: {0}", byteVal1.Equals(byteVal2));
    Console.WriteLine("byteVal1 equals objectVal3?: {0}", byteVal1.Equals(objectVal3));
    }
}

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