mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-06 14:27:26 +08:00
feat(csharp/hashing): add code and update docs to chapter hashing (#568)
* feat(csharp/hashing): add code and update docs to chapter hashing * revert linked list to list
This commit is contained in:
@ -338,7 +338,29 @@ $$
|
||||
=== "C#"
|
||||
|
||||
```csharp title="built_in_hash.cs"
|
||||
int num = 3;
|
||||
int hashNum = num.GetHashCode();
|
||||
// 整数 3 的哈希值为 3;
|
||||
|
||||
bool bol = true;
|
||||
int hashBol = bol.GetHashCode();
|
||||
// 布尔量 true 的哈希值为 1;
|
||||
|
||||
double dec = 3.14159;
|
||||
int hashDec = dec.GetHashCode();
|
||||
// 小数 3.14159 的哈希值为 -1340954729;
|
||||
|
||||
string str = "Hello 算法";
|
||||
int hashStr = str.GetHashCode();
|
||||
// 字符串 Hello 算法 的哈希值为 -586107568;
|
||||
|
||||
object[] arr = { 12836, "小哈" };
|
||||
int hashTup = arr.GetHashCode();
|
||||
// 数组 [12836, 小哈] 的哈希值为 42931033;
|
||||
|
||||
ListNode obj = new ListNode(0);
|
||||
int hashObj = obj.GetHashCode();
|
||||
// 节点对象 0 的哈希值为 39053774;
|
||||
```
|
||||
|
||||
=== "Swift"
|
||||
|
Reference in New Issue
Block a user