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 新娘父亲婚礼简短祝福语
14 开工出货大吉祝福语 简短
15 小班春节祝福语大全简短
16 漆沙沙老师祝福语简短
17 领生日祝福语 简短独特
18 18岁生日简短祝福语