C#| Uri.Equals()方法与示例
Uri.Equals()方法
Uri.Equals()方法是一个覆盖方法,用于检查与当前对象的指定引用是否相等。如果两者相等,则返回true,否则返回false。
语法:
bool Uri.Equals(Uri obj);
Parameter(s):
Uriobj–表示要与当前对象检查的指定对象。
返回值:
此方法的返回类型为Boolean,如果指定的对象或引用等于当前对象,则返回布尔值,然后返回true,否则返回false。
举例说明方法的例子Uri.Equals()
using System;
class UriExample
{
//程序入口
static public void Main()
{
Uri domainUri1;
Uri domainUri2;
Uri domainUri3;
domainUri1 = new Uri("https://www.nhooo.com/index.html");
domainUri2 = new Uri("https://www.nhooo.com/index.html");
domainUri3 = new Uri("https://www.nhooo.com/index_1.html");
if (domainUri1.Equals(domainUri1) == true)
Console.WriteLine("Both are equal");
else
Console.WriteLine("Both are not equal");
if (domainUri1.Equals(domainUri2) == true)
Console.WriteLine("Both are equal");
else
Console.WriteLine("Both are not equal");
if (domainUri1.Equals(domainUri3) == true)
Console.WriteLine("Both are equal");
else
Console.WriteLine("Both are not equal");
}
}输出结果
Both are equal Both are equal Both are not equal
热门推荐
10 医院探望朋友祝福语简短
11 毕业祝福语简短女朋友
12 春节虎年爸妈祝福语简短
13 儿童毕业祝福语 简短6
14 开工仪式横幅祝福语简短
15 孩子日常祝福语大全简短
16 清晨寄语诗句祝福语简短
17 结婚送亲认亲祝福语简短
18 虎年喝酒拜年祝福语简短