Uri.Compare(Uri, Uri, UriComponents, UriFormat, StringComparison) Method

Definition

使用指定的比較規則,比較兩個 URI 的指定部分。Compares the specified parts of two URIs using the specified comparison rules.

public:
 static int Compare(Uri ^ uri1, Uri ^ uri2, UriComponents partsToCompare, UriFormat compareFormat, StringComparison comparisonType);
public static int Compare (Uri uri1, Uri uri2, UriComponents partsToCompare, UriFormat compareFormat, StringComparison comparisonType);
static member Compare : Uri * Uri * UriComponents * UriFormat * StringComparison -> int
Public Shared Function Compare (uri1 As Uri, uri2 As Uri, partsToCompare As UriComponents, compareFormat As UriFormat, comparisonType As StringComparison) As Integer

Parameters

uri1
Uri

第一個 UriThe first Uri.

uri2
Uri

第二個 UriThe second Uri.

partsToCompare
UriComponents

UriComponents 值的位元組合,指定要比較之 uri1uri2 的部分。A bitwise combination of the UriComponents values that specifies the parts of uri1 and uri2 to compare.

compareFormat
UriFormat

UriFormat 值之一,指定比較 URI 元件時所使用的字元逸出方式。One of the UriFormat values that specifies the character escaping used when the URI components are compared.

comparisonType
StringComparison

其中一個 StringComparison 值。One of the StringComparison values.

Returns

Int32

Int32 值,表示所比較之 Uri 元件間的語彙關聯性。An Int32 value that indicates the lexical relationship between the compared Uri components.

Value 意義Meaning
小於零Less than zero uri1 小於 uri2uri1 is less than uri2.
Zero uri1等於 uri2uri1 equals uri2.
大於零Greater than zero uri1 大於 uri2uri1 is greater than uri2.

Exceptions

comparisonType 不是有效的 StringComparison 值。comparisonType is not a valid StringComparison value.

Remarks

如果 uri1uri2null,這個方法會傳回0。If both uri1 and uri2 are null, this method returns 0. 比較 URI 值時,相對 URI 一律小於絕對 URI,而非 null URI 一律大於 null URI。When comparing URI values, a relative URI is always less than an absolute URI, and a non-null URI is always greater than a null URI. 對於 uri1uri2 都不 null 且同時為相對 Uri 或兩者都是絕對 Uri 的情況,String.Compare(String, String, StringComparison) 方法會執行比較。For cases where both uri1 and uri2 are not null and are both relative URIs or both absolute URIs, the String.Compare(String, String, StringComparison) method performs the comparison.

Applies to