Leggere in inglese

Condividi tramite


Byte.Equals Metodo

Definizione

Restituisce un valore che indica se due istanze di Byte rappresentano lo stesso valore.

Overload

Equals(Byte)

Restituisce un valore che indica se l'istanza e un oggetto Byte specificato rappresentano lo stesso valore.

Equals(Object)

Restituisce un valore che indica se questa istanza è uguale a un oggetto specificato.

Esempio

L'esempio di codice seguente determina se il primo valore è uguale al secondo valore e se il primo ByteByte valore è uguale alla versione casellata del secondo ByteByte valore.

// This code example demonstrates the System.Byte.Equals(Object) and
// System.Byte.Equals(Byte) methods.

using System;

class Sample
{
    public static void Main()
    {
    byte   byteVal1 = 0x7f;
    byte   byteVal2 = 127;
    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));
    }
}

/*
This code example produces the following results:

byteVal1 = 127, byteVal2 = 127, objectVal3 = 127

byteVal1 equals byteVal2?: True
byteVal1 equals objectVal3?: True

*/

Equals(Byte)

Origine:
Byte.cs
Origine:
Byte.cs
Origine:
Byte.cs

Restituisce un valore che indica se l'istanza e un oggetto Byte specificato rappresentano lo stesso valore.

public bool Equals (byte obj);

Parametri

obj
Byte

Oggetto da confrontare con questa istanza.

Restituisce

true se obj è uguale all'istanza; in caso contrario, false.

Implementazioni

Commenti

Questo metodo implementa l'interfaccia ed esegue leggermente meglio di Equals(Object) perché non deve convertire il System.IEquatable<T>obj parametro in un oggetto.

Vedi anche

Si applica a

Equals(Object)

Origine:
Byte.cs
Origine:
Byte.cs
Origine:
Byte.cs

Restituisce un valore che indica se questa istanza è uguale a un oggetto specificato.

public override bool Equals (object obj);
public override bool Equals (object? obj);

Parametri

obj
Object

Oggetto da confrontare con questa istanza o null.

Restituisce

true se obj è un'istanza di Byte ed è uguale al valore dell'istanza; in caso contrario, false.

Vedi anche

Si applica a