共用方式為


Operators.hash<'T> 函式 (F#)

A generic hash function, designed to return equal hash values for items that are equal according to the = operator. 它預設會使用 F# 聯集的結構化雜湊、記錄和 Tuple 型別,來產生型別之完整內容的雜湊。 函式的確切的行為可以根據不同的型別調整藉由實作 GetHashCode的 每個型別。

命名空間/模組路徑:Microsoft.FSharp.Core.Operators

組件:FSharp.Core (在 FSharp.Core.dll 中)

// Signature:
hash : 'T -> int (requires equality)

// Usage:
hash obj

參數

  • obj
    型別:'T

    輸入物件。

傳回值

已處理的雜湊。

備註

這個函式是名為 Hash中 已編譯的組件。 如果從一個語言,F # 以外,或透過反映存取函式使用這個名稱。

範例

The following examples shows the use of the hash function to generate hashes for a variety of data types.

let show a = printfn "hash(%A) : %d" a (hash a) 
show 1;
show 2;
show "1"
show "2"
show "abb" 
show "aBc" // case-sensitive
show None;
show (Some 1);
show (Some 0);
show [1;2;3];
show [1;2;3;4;5;6;7;8];
show [1;2;3;4;5;6;7;8;9;10;11];
show [1;2;3;4;5;6;7;8;9;10;11;12;13;14;15]
  

平台

Windows 7、Windows Vista SP2、Windows XP SP3、Windows XP x64 SP2、Windows Server 2008 R2、Windows Server 2008 SP2、Windows Server 2003 SP2

版本資訊

F# 執行階段

支援版本:2.0、4.0

Silverlight

支援版本:3

請參閱

參考

Core.Operators 模組 (F#)

Microsoft.FSharp.Core 命名空間 (F#)