Compare Method

Uri.Compare Method

Compares the specified parts of two URIs using the specified comparison rules.

Namespace:  System
Assembly:  System (in System.dll)

static member Compare : 
        uri1:Uri * 
        uri2:Uri * 
        partsToCompare:UriComponents * 
        compareFormat:UriFormat * 
        comparisonType:StringComparison -> int 


Type: System.Uri
The first Uri.
Type: System.Uri
The second Uri.
Type: System.UriComponents
A bitwise combination of the UriComponents values that specifies the parts of uri1 and uri2 to compare.
Type: System.UriFormat
One of the UriFormat values that specifies the character escaping used when the URI components are compared.
Type: System.StringComparison
One of the StringComparison values.

Return Value

Type: System.Int32
An Int32 value that indicates the lexical relationship between the compared Uri components.



Less than zero

uri1 is less than uri2.


uri1 equals uri2.

Greater than zero

uri1 is greater than uri2.


comparisonType is not a valid StringComparison value.

If both uri1 and uri2 are a null reference (Nothing in Visual Basic), this method returns 0. 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. For cases where both uri1 and uri2 are not a null reference (Nothing in Visual Basic) and are both relative URIs or both absolute URIs, the String.Compare(String, String, StringComparison) method performs the comparison.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2015 Microsoft