Share via


UnicodeEncoding.GetHashCode Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Returns the hash code for the current instance.

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

Syntax

'Declaration
Public Overrides Function GetHashCode As Integer
public override int GetHashCode()

Return Value

Type: System.Int32
The hash code for the current UnicodeEncoding object.

Examples

The following code example demonstrates how to use the GetHashCode method to return a hash code for a UnicodeEncoding object. Regardless of how the UnicodeEncoding object is created, all objects return the same hash code.

Imports System.Text

Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim unicode1 As New UnicodeEncoding()
      Dim unicode2 As Encoding = Encoding.Unicode

      outputBlock.Text &= unicode1.GetHashCode() & vbCrLf
      outputBlock.Text &= unicode2.GetHashCode() & vbCrLf
   End Sub 'Main 
End Class 'UnicodeEncodingExample
using System;
using System.Text;

class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      UnicodeEncoding unicode1 = new UnicodeEncoding();
      Encoding unicode2 = Encoding.Unicode;

      outputBlock.Text += unicode1.GetHashCode() + "\n";
      outputBlock.Text += unicode2.GetHashCode() + "\n";

   }
}

Version Information

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

Platforms

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