当前位置: 首页 > 工具软件 > URI.js > 使用案例 >

c# uri.host_C#| 具有示例的Uri.Equality()运算符

齐雅畅
2023-12-01

c# uri.host

Uri.Equality()运算符 (Uri.Equality() Operator)

Uri.Equality() Operator is overloaded which is used to compare two Uri objects. It returns true if two Uri objects contain the same Uri otherwise it returns false.

Uri.Equality()运算符已重载,该运算符用于比较两个Uri对象。 如果两个开放的对象包含相同的URI否则返回false返回true。

Syntax:

句法:

    bool operator == (Uri uri1, Uri uri2);

Parameter(s):

参数:

  • Uri uri1 – represents the first Uri to be compared.

    Uri uri1 –表示要比较的第一个Uri。

  • Uri uri2 – represents the second Uri to be compared.

    Uri uri2 –表示要比较的第二个Uri。

Return value:

返回值:

The return type of this method is Boolean, it returns true if the Uri instances are the same; otherwise, false.

此方法的返回类型为Boolean ,如果Uri实例相同,则返回true;否则,返回true 。 否则为false

Example to demonstrate example of Uri.Equality() Operator

演示Uri.Equality()运算符示例的示例

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        // Create some Uri objects
        Uri uri1 = new Uri("https://www.includehelp.com/");
        Uri uri2 = new Uri("https://www.includehelp.com/");
        Uri uri3 = new Uri("https://www.includehelp.com/index.html");

        if (uri1 == uri2)
            Console.WriteLine("uri1 and uri2 are equal");
        else
            Console.WriteLine("uri1 and uri2 are not equal");

        if (uri1 == uri3)
            Console.WriteLine("uri1 and uri3 are equal");
        else
            Console.WriteLine("uri1 and uri3 are not equal");
    }
}

Output

输出量

uri1 and uri2 are equal
uri1 and uri3 are not equal

Reference: Uri.Equality(Uri, Uri) Operator

参考: Uri.Equality(Uri,Uri)运算符

翻译自: https://www.includehelp.com/dot-net/uri-equality-operator-with-example.aspx

c# uri.host

 类似资料: