Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UTF8Encoding::GetHashCode Method ()

 

Returns the hash code for the current instance.

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

public:
virtual int GetHashCode() override

Return Value

Type: System::Int32

The hash code for the current instance.

The following example uses the GetHashCode method to return a hash code for UTF8Encoding instances. Notice that the hash code returned by this method depends on the constructor used to create the UTF8Encoding object.

using namespace System;
using namespace System::Text;
int main()
{

   // Many ways to instantiate a UTF8 encoding.
   UTF8Encoding^ UTF8a = gcnew UTF8Encoding;
   Encoding^ UTF8b = Encoding::UTF8;
   Encoding^ UTF8c = gcnew UTF8Encoding( true,true );
   Encoding^ UTF8d = gcnew UTF8Encoding( false,false );

   // But not all are the same.
   Console::WriteLine( UTF8a->GetHashCode() );
   Console::WriteLine( UTF8b->GetHashCode() );
   Console::WriteLine( UTF8c->GetHashCode() );
   Console::WriteLine( UTF8d->GetHashCode() );
}

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2017 Microsoft