This documentation is archived and is not being maintained.

UTF8Encoding.GetHashCode Method

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

using System;
using System.Text;

class UTF8EncodingExample {
    public static void Main() {
        // Many ways to instantiate a UTF8 encoding.
        UTF8Encoding UTF8a = new UTF8Encoding();
        Encoding UTF8b = Encoding.UTF8;
        Encoding UTF8c = new UTF8Encoding(true, true);
        Encoding UTF8d = new UTF8Encoding(false, false);

        // But not all are the same.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.