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.tw/index.htm");
Console.WriteLine("URI = "+newURI1);
Uri newURI2 = new Uri("https://tutorialspoint.tw/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.tw/index.htm URI = https://tutorialspoint.tw/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.tw/index.htm");
Console.WriteLine("URI = "+newURI1);
Uri newURI2 = new Uri("https://tutorialspoint.tw/");
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.tw/index.htm URI = https://tutorialspoint.tw/ Both the URIs aren't equal!
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP