GetHashCode Method

UTF8Encoding.GetHashCode Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft