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 婚前女儿生日祝福语简短