UTF8Encoding.Equals(Object) UTF8Encoding.Equals(Object) UTF8Encoding.Equals(Object) UTF8Encoding.Equals(Object) Method

Definición

Determina si el objeto especificado es igual al objeto UTF8Encoding actual.Determines whether the specified object is equal to the current UTF8Encoding object.

public:
 override bool Equals(System::Object ^ value);
public override bool Equals (object value);
override this.Equals : obj -> bool
Public Overrides Function Equals (value As Object) As Boolean

Parámetros

value
Object Object Object Object

Objeto que se va a comparar con la instancia actual.The object to compare with the current instance.

Devoluciones

true si value es una instancia de UTF8Encoding y es igual al objeto actual; en caso contrario, false.true if value is an instance of UTF8Encoding and is equal to the current object; otherwise, false.

Ejemplos

En el ejemplo siguiente se usa el Equals método para probar si el actual UTF8Encoding es igual a otro objeto UTF8Encoding objeto.The following example uses the Equals method to test whether the current UTF8Encoding object is equal to a different UTF8Encoding object. Cuatro UTF8Encoding objetos se crean y se comparan y se muestran los resultados de las comparaciones.Four UTF8Encoding objects are created and compared and the results of the comparisons are displayed.

using namespace System;
using namespace System::Text;
void DescribeEquivalence( Boolean isEquivalent )
{
   Console::WriteLine( "{0} equivalent encoding.", (isEquivalent ? (String^)"An" : "Not an") );
}

int main()
{
   UTF8Encoding^ utf8 = gcnew UTF8Encoding;
   UTF8Encoding^ utf8true = gcnew UTF8Encoding( true );
   UTF8Encoding^ utf8truetrue = gcnew UTF8Encoding( true,true );
   UTF8Encoding^ utf8falsetrue = gcnew UTF8Encoding( false,true );
   DescribeEquivalence( utf8->Equals( utf8 ) );
   DescribeEquivalence( utf8->Equals( utf8true ) );
   DescribeEquivalence( utf8->Equals( utf8truetrue ) );
   DescribeEquivalence( utf8->Equals( utf8falsetrue ) );
   DescribeEquivalence( utf8true->Equals( utf8 ) );
   DescribeEquivalence( utf8true->Equals( utf8true ) );
   DescribeEquivalence( utf8true->Equals( utf8truetrue ) );
   DescribeEquivalence( utf8true->Equals( utf8falsetrue ) );
   DescribeEquivalence( utf8truetrue->Equals( utf8 ) );
   DescribeEquivalence( utf8truetrue->Equals( utf8true ) );
   DescribeEquivalence( utf8truetrue->Equals( utf8truetrue ) );
   DescribeEquivalence( utf8truetrue->Equals( utf8falsetrue ) );
   DescribeEquivalence( utf8falsetrue->Equals( utf8 ) );
   DescribeEquivalence( utf8falsetrue->Equals( utf8true ) );
   DescribeEquivalence( utf8falsetrue->Equals( utf8truetrue ) );
   DescribeEquivalence( utf8falsetrue->Equals( utf8falsetrue ) );
}

using System;
using System.Text;

class UTF8EncodingExample {
    public static void Main() {
        UTF8Encoding utf8 = new UTF8Encoding();
        UTF8Encoding utf8true = new UTF8Encoding(true);
        UTF8Encoding utf8truetrue = new UTF8Encoding(true, true);
        UTF8Encoding utf8falsetrue = new UTF8Encoding(false, true);
        
        DescribeEquivalence(utf8.Equals(utf8));
        DescribeEquivalence(utf8.Equals(utf8true));
        DescribeEquivalence(utf8.Equals(utf8truetrue));
        DescribeEquivalence(utf8.Equals(utf8falsetrue));
        
        DescribeEquivalence(utf8true.Equals(utf8));
        DescribeEquivalence(utf8true.Equals(utf8true));
        DescribeEquivalence(utf8true.Equals(utf8truetrue));
        DescribeEquivalence(utf8true.Equals(utf8falsetrue));
        
        DescribeEquivalence(utf8truetrue.Equals(utf8));
        DescribeEquivalence(utf8truetrue.Equals(utf8true));
        DescribeEquivalence(utf8truetrue.Equals(utf8truetrue));
        DescribeEquivalence(utf8truetrue.Equals(utf8falsetrue));
        
        DescribeEquivalence(utf8falsetrue.Equals(utf8));
        DescribeEquivalence(utf8falsetrue.Equals(utf8true));
        DescribeEquivalence(utf8falsetrue.Equals(utf8truetrue));
        DescribeEquivalence(utf8falsetrue.Equals(utf8falsetrue));
    }

    public static void DescribeEquivalence(Boolean isEquivalent) {
        Console.WriteLine(
            "{0} equivalent encoding.", (isEquivalent ? "An" : "Not an")
        );
    }
}
Imports System
Imports System.Text

Class UTF8EncodingExample
    
    Public Shared Sub Main()
        Dim utf8 As New UTF8Encoding()
        Dim utf8true As New UTF8Encoding(True)
        Dim utf8truetrue As New UTF8Encoding(True, True)
        Dim utf8falsetrue As New UTF8Encoding(False, True)
        
        DescribeEquivalence(utf8.Equals(utf8))
        DescribeEquivalence(utf8.Equals(utf8true))
        DescribeEquivalence(utf8.Equals(utf8truetrue))
        DescribeEquivalence(utf8.Equals(utf8falsetrue))
        
        DescribeEquivalence(utf8true.Equals(utf8))
        DescribeEquivalence(utf8true.Equals(utf8true))
        DescribeEquivalence(utf8true.Equals(utf8truetrue))
        DescribeEquivalence(utf8true.Equals(utf8falsetrue))
        
        DescribeEquivalence(utf8truetrue.Equals(utf8))
        DescribeEquivalence(utf8truetrue.Equals(utf8true))
        DescribeEquivalence(utf8truetrue.Equals(utf8truetrue))
        DescribeEquivalence(utf8truetrue.Equals(utf8falsetrue))
        
        DescribeEquivalence(utf8falsetrue.Equals(utf8))
        DescribeEquivalence(utf8falsetrue.Equals(utf8true))
        DescribeEquivalence(utf8falsetrue.Equals(utf8truetrue))
        DescribeEquivalence(utf8falsetrue.Equals(utf8falsetrue))
    End Sub 'Main
    
    
    Public Shared Sub DescribeEquivalence(isEquivalent As Boolean)
        Dim phrase as String
        If isEquivalent Then
            phrase = "An"
        Else
            phrase = "Not an"
        End If
        Console.WriteLine("{0} equivalent encoding.", phrase)
    End Sub 'DescribeEquivalence
End Class 'UTF8EncodingExample

Comentarios

Dos UTF8Encoding objetos se consideran iguales si se cumplen todas las condiciones siguientes:Two UTF8Encoding objects are considered equal if all of the following conditions are true:

  • Ambos objetos proporcionan la marca de orden de bytes, o ambos no lo hacen.Both objects provide the byte order mark, or both do not.

  • Ambos objetos utilizan la misma reserva del codificador.Both objects use the same encoder fallback.

  • Ambos objetos utilizan la misma reserva del descodificador.Both objects use the same decoder fallback.

Se aplica a

Consulte también: