UTF8Encoding.GetHashCode Method

Returns the hash code for the current instance.

Namespace:  System.Text
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Overrides Function GetHashCode As Integer

Return Value

Type: System.Int32
The hash code for the current instance.

The following example demonstrates how to use the GetHashCode method to return a hash code for an instance of UTF8Encoding. Notice that the hash code returned by this method varies depending on the constructor used to create the UTF8Encoding.


Imports System.Text

Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      ' Many ways to instantiate a UTF8 encoding.
      Dim UTF8a As New UTF8Encoding()
      Dim UTF8b As Encoding = Encoding.UTF8
      Dim UTF8c = New UTF8Encoding(True, True)
      Dim UTF8d = New UTF8Encoding(False, False)

      ' But not all are the same.
      outputBlock.Text &= UTF8a.GetHashCode() & vbCrLf
      outputBlock.Text &= UTF8b.GetHashCode() & vbCrLf
      outputBlock.Text &= UTF8c.GetHashCode() & vbCrLf
      outputBlock.Text &= UTF8d.GetHashCode() & vbCrLf
   End Sub 'Main
End Class 'UTF8EncodingExample


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: