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 婆婆高寿祝福语大全简短