dotnet / dotnet/dotnet-api-docs

Information seems contradictory

Open
#1,247 0 comments 0 reactions 0 assignees View on GitHub
area-System.Runtime dotnet-api/prod Pri2 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

Regarding the last information box (emphasis mine).

> Hash codes are used to **insert and retrieve keyed objects from hash tables** efficiently. ... Because of this, you should not serialize or persist hash code values, **nor should you use them as keys in a hash table** or dictionary.

I understand the general information of `GetHashCode()` being randomized so you can't rely on it across program executions etc, but saying hash codes are used to insert values into hash tables, but that you shouldn't use them as keys in a hash table seems contradictory?

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 46e1d9ef-f477-c47a-da4e-88feb95f6dc9
* Version Independent ID: acedf195-f641-b347-39a9-7b3a43d32e00
* Content: [String.GetHashCode Method (System)](https://docs.microsoft.com/en-us/dotnet/api/system.string.gethashcode?view=netframework-4.7.2)
* Content Source: [xml/System/String.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System/String.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.