GetHashCode Method

UnicodeEncoding.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)

public override int GetHashCode()

Return Value

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

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.

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";


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2016 Microsoft