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

定义

使用指定的比较规则比较两个 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

参数

uri1
Uri Uri Uri Uri

第一个 UriThe first Uri.

uri2
Uri Uri Uri Uri

第二个 UriThe second Uri.

partsToCompare
UriComponents UriComponents UriComponents UriComponents

UriComponents 值的按位组合,它指定要比较的 uri1uri2 的部分。A bitwise combination of the UriComponents values that specifies the parts of uri1 and uri2 to compare.

compareFormat
UriFormat UriFormat UriFormat UriFormat

UriFormat 值中的一个,它指定在比较 URI 部分时使用的字符转义。One of the UriFormat values that specifies the character escaping used when the URI components are compared.

返回

一个 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.

异常

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

注解

uri1如果和uri2均为null, 则此方法返回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. 对于uri1uri2String.Compare(String, String, StringComparison)null是并且既是相对 uri, 也不是这两个绝对 uri 的情况, 方法将执行比较。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.

适用于