C# 中的 Uri.Equals(Object) 方法
C# 中的 Uri.Equals() 方法比较两个 Uri 实例是否相等。
语法
以下为语法 −
public override bool Equals (object comparand);
上述参数 comparand 是要与当前实例进行比较的 Uri 实例或 URI 标识符。
示例
我们现在来看个示例来实现 Uri.Equals() 方法 −
using System;
public class Demo {
public static void Main(){
Uri newURI1 = new Uri("https://tutorialspoint.com/index.htm");
Console.WriteLine("URI = "+newURI1);
Uri newURI2 = new Uri("https://tutorialspoint.com/index.htm");
Console.WriteLine("URI = "+newURI2);
if(newURI1.Equals(newURI2))
Console.WriteLine("Both the URIs are equal!");
else
Console.WriteLine("Both the URIs aren't equal!");
}
}输出
这会生成以下输出 −
URI = https://tutorialspoint.com/index.htm URI = https://tutorialspoint.com/index.htm Both the URIs aren't equal!
示例
我们现在来看另一个示例来实现 Uri.Equals() 方法 −
using System;
public class Demo {
public static void Main(){
Uri newURI1 = new Uri("https://tutorialspoint.com/index.htm");
Console.WriteLine("URI = "+newURI1);
Uri newURI2 = new Uri("https://tutorialspoint.com/");
Console.WriteLine("URI = "+newURI2);
if(newURI1.Equals(newURI2))
Console.WriteLine("Both the URIs are equal!");
else
Console.WriteLine("Both the URIs aren't equal!");
}
}输出
这会生成以下输出 −
URI = https://tutorialspoint.com/index.htm URI = https://tutorialspoint.com/ Both the URIs aren't equal!
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP