文档

Unity Engine

Unity Engine

GetHashCode()

Computes a hash code for this identifier.
阅读时间1 分钟最后更新于 1 个月前

Definition

  • Type: Method
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule
public override int GetHashCode()

Returns

Type

Description

intAn integer hash code derived from the culture code.

Remarks

Consistent with LocaleIdentifier.Equals: identifiers that compare equal produce the same hash code, because the code is hashed case-insensitively. The undefined identifier hashes to
0
. Safe to use as a dictionary key.
Use an identifier as a dictionary key.

Examples

using System.Collections.Generic;using Unity.Localization;namespace Unity.Localization.Samples{ public class LocaleIdentifierHashCodeExample { public void Run(LocaleIdentifier identifier) { var counts = new Dictionary<LocaleIdentifier, int>(); counts[identifier] = counts.GetValueOrDefault(identifier) + 1; } }}