Uri.GetHashCode() 方法(C# 中)
C# 中的 Uri.GetHashCode() 方法可获取 URI 的哈希代码。
语法
以下是语法:
public override int GetHashCode ();
int GetHashCode()
示例
using System;
public class Demo {
public static void Main(){
string URI1 = "https://tutorialspoint.com/index.htm";
Console.WriteLine("URI = "+URI1);
string URI2 = "https://tutorialspoint.com/";
Console.WriteLine("URI = "+URI2);
Console.WriteLine("Escaped string (URI1) = "+Uri.EscapeDataString(URI1));
Console.WriteLine("Escaped string (URI2) = "+Uri.EscapeDataString(URI2));
Console.WriteLine("GetHashCode() for URI1 = "+URI1.GetHashCode());
Console.WriteLine("GetHashCode() for URI2 = "+URI2.GetHashCode());
}
}让我们看一个示例来实现 Uri.GetHashCode() 方法:
C#
URI = https://tutorialspoint.com/index.htm URI = https://tutorialspoint.com/ Escaped string (URI1) = https%3A%2F%2Fwww.tutorialspoint.com%2Findex.htm Escaped string (URI2) = https%3A%2F%2Fwww.tutorialspoint.com%2F GetHashCode() for URI1 = -799747664 GetHashCode() for URI2 = 211597894
int GetHashCode()
输出
using System;
public class Demo {
public static void Main(){
string URI1 = "https://www.qries.com/index.htm";
Console.WriteLine("URI = "+URI1);
string URI2 = "https://www.qries.com/";
Console.WriteLine("URI = "+URI2);
Console.WriteLine("Escaped string (URI1) = "+Uri.EscapeDataString(URI1));
Console.WriteLine("Escaped string (URI2) = "+Uri.EscapeDataString(URI2));
Console.WriteLine("GetHashCode() for URI1 = "+URI1.GetHashCode());
Console.WriteLine("GetHashCode() for URI2 = "+URI2.GetHashCode());
}
}让我们看一个示例来实现 Uri.GetHashCode() 方法:
C#
URI = https://www.qries.com/index.htm URI = https://www.qries.com/ Escaped string (URI1) = https%3A%2F%2Fwww.qries.com%2Findex.htm Escaped string (URI2) = https%3A%2F%2Fwww.qries.com%2F GetHashCode() for URI1 = -39330946 GetHashCode() for URI2 = -262746624
广告
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP