hello-algo/codes/csharp/chapter_hashing/built_in_hash.cs
hpstory f62256bee1
fix(csharp): Modify method name to PascalCase, simplify new expression (#840)
* Modify method name to PascalCase(array and linked list)

* Modify method name to PascalCase(backtracking)

* Modify method name to PascalCase(computational complexity)

* Modify method name to PascalCase(divide and conquer)

* Modify method name to PascalCase(dynamic programming)

* Modify method name to PascalCase(graph)

* Modify method name to PascalCase(greedy)

* Modify method name to PascalCase(hashing)

* Modify method name to PascalCase(heap)

* Modify method name to PascalCase(searching)

* Modify method name to PascalCase(sorting)

* Modify method name to PascalCase(stack and queue)

* Modify method name to PascalCase(tree)

* local check
2023-10-07 12:33:46 -05:00

36 lines
1.1 KiB
C#

/**
* File: built_in_hash.cs
* Created Time: 2023-06-26
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_hashing;
public class built_in_hash {
[Test]
public void Test() {
int num = 3;
int hashNum = num.GetHashCode();
Console.WriteLine("整数 " + num + " 的哈希值为 " + hashNum);
bool bol = true;
int hashBol = bol.GetHashCode();
Console.WriteLine("布尔量 " + bol + " 的哈希值为 " + hashBol);
double dec = 3.14159;
int hashDec = dec.GetHashCode();
Console.WriteLine("小数 " + dec + " 的哈希值为 " + hashDec);
string str = "Hello 算法";
int hashStr = str.GetHashCode();
Console.WriteLine("字符串 " + str + " 的哈希值为 " + hashStr);
object[] arr = { 12836, "小哈" };
int hashTup = arr.GetHashCode();
Console.WriteLine("数组 [" + string.Join(", ", arr) + "] 的哈希值为 " + hashTup);
ListNode obj = new(0);
int hashObj = obj.GetHashCode();
Console.WriteLine("节点对象 " + obj + " 的哈希值为 " + hashObj);
}
}