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.

CompareInfo::GetHashCode Method (String^, CompareOptions)

.NET Framework (current version)
 

Gets the hash code for a string based on specified comparison options.

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

public:
virtual int GetHashCode(
	String^ source,
	CompareOptions options
)

Parameters

source
Type: System::String^

The string whose hash code is to be returned.

options
Type: System.Globalization::CompareOptions

A value that determines how strings are compared.

Return Value

Type: System::Int32

A 32-bit signed integer hash code.

Exception Condition
ArgumentNullException

source is null.

The behavior of GetHashCode is dependent on its implementation, which might change from one version of the common language runtime to another, or from one .NET Framework platform to another.

System_CAPS_importantImportant

If two string objects are equal, the GetHashCode method returns identical values. However, there is not a unique hash code value for each unique string value. Different strings can return the same hash code.

The hash code itself is not guaranteed to be stable. Hash codes for identical strings can differ across versions of the .NET Framework and across platforms (such as 32-bit and 64-bit) for a single version of the .NET Framework. In some cases, they can even differ by application domain.

As a result, hash codes should never be used outside of the application domain in which they were created, they should never be used as key fields in a collection, and they should never be persisted.

Universal Windows Platform
Available since 10
.NET Framework
Available since 4.6
Return to top
Show:
© 2017 Microsoft