UTF8Encoding: Equals

Equals

Determines whether the specified value is equal to the current UTF8Encoding object.



 Public Function Equals(
	  ByRef Value As Variant ) As Boolean

Parameters

Value
[ByRef] Variant. The value to compare with the current instance.

Return Values

Boolean -  True if value is an instance of UTF8Encoding and is equal to the current object; otherwise, False.

Remarks

Two UTF8Encoding objects are considered equal if all of the following conditions are true:

Examples

The following example demonstrates how to use the Equals method to test whether the current UTF8Encoding object is equal to a different UTF8Encoding object. Four UTF8Encoding objects are created and compared and the results of the comparisons are displayed.

Public Sub Main()
    Dim UTF8 As UTF8Encoding
    Dim UTF8True As UTF8Encoding
    Dim UTF8TrueTrue As UTF8Encoding
    Dim UTF8FalseTrue As UTF8Encoding
    
    Set UTF8 = New UTF8Encoding
    Set UTF8True = NewUTF8Encoding(True)
    Set UTF8TrueTrue = NewUTF8Encoding(True, True)
    Set UTF8FalseTrue = NewUTF8Encoding(False, True)
    
    DescribeEquivalence UTF8.Equals(UTF8)
    DescribeEquivalence UTF8.Equals(UTF8True)
    DescribeEquivalence UTF8.Equals(UTF8TrueTrue)
    DescribeEquivalence UTF8.Equals(UTF8FalseTrue)
    Console.WriteLine

    DescribeEquivalence UTF8True.Equals(UTF8)
    DescribeEquivalence UTF8True.Equals(UTF8True)
    DescribeEquivalence UTF8True.Equals(UTF8TrueTrue)
    DescribeEquivalence UTF8True.Equals(UTF8FalseTrue)
    Console.WriteLine

    DescribeEquivalence UTF8TrueTrue.Equals(UTF8)
    DescribeEquivalence UTF8TrueTrue.Equals(UTF8True)
    DescribeEquivalence UTF8TrueTrue.Equals(UTF8TrueTrue)
    DescribeEquivalence UTF8TrueTrue.Equals(UTF8FalseTrue)
    Console.WriteLine

    DescribeEquivalence UTF8FalseTrue.Equals(UTF8)
    DescribeEquivalence UTF8FalseTrue.Equals(UTF8True)
    DescribeEquivalence UTF8FalseTrue.Equals(UTF8TrueTrue)
    DescribeEquivalence UTF8FalseTrue.Equals(UTF8FalseTrue)
    
    Console.ReadKey
End Sub

Private Sub DescribeEquivalence(ByVal IsEquivalent As Boolean)
    Console.WriteLine "{0} equivalent encoding.", IIf(IsEquivalent, "An", "Not an")
End Sub

' This code produces the following output.
'
'    An equivalent encoding.
'    Not an equivalent encoding.
'    Not an equivalent encoding.
'    Not an equivalent encoding.
'
'    Not an equivalent encoding.
'    An equivalent encoding.
'    Not an equivalent encoding.
'    Not an equivalent encoding.
'
'    Not an equivalent encoding.
'    Not an equivalent encoding.
'    An equivalent encoding.
'    Not an equivalent encoding.
'
'    Not an equivalent encoding.
'    Not an equivalent encoding.
'    Not an equivalent encoding.
'    An equivalent encoding.

See Also

Project CorLib Overview

Class UTF8Encoding Overview