Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Inequality Operator
Collapse the table of content
Expand the table of content

Uri.Inequality Operator

Determines whether two Uri instances do not have the same value.

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

public static bool operator !=(
	Uri uri1,
	Uri uri2
)

Parameters

uri1
Type: System.Uri

A Uri instance to compare with uri2.

uri2
Type: System.Uri

A Uri instance to compare with uri1.

Return Value

Type: System.Boolean
A Boolean value that is true if the two Uri instances are not equal; otherwise, false. If either parameter is null, this method returns true.

This overload uses the Equals method to determine whether the two Uri instances are not equivalent. UserInfo and Fragment content is ignored when making this comparison.

This example creates three Uri instances from strings and compares them to determine whether they represent the same value. Address2 and Address3 are not the same because Address3 contains a Query that is not found in Address2. The outcome is written to the console.

// Create some Uris.
Uri address1 = new Uri("http://www.contoso.com/index.htm#search");
Uri address2 = new Uri("http://www.contoso.com/index.htm"); 
Uri address3 = new Uri("http://www.contoso.com/index.htm?date=today"); 

// The first two are equal because the fragment is ignored. 
if (address1 == address2)
    Console.WriteLine("{0} is equal to {1}", address1.ToString(), address2.ToString());

// The second two are not equal. 
if (address2 != address3)
    Console.WriteLine("{0} is not equal to {1}", address2.ToString(), address3.ToString());

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft