C# Uri Inequality

Description

Uri Inequality determines whether two Uri instances do not have the same value.

Syntax

Uri.Inequality has the following syntax.


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

Parameters

Uri.Inequality has the following parameters.

  • uri1 - A Uri instance to compare with uri2.
  • uri2 - A Uri instance to compare with uri1.

Returns

Uri.Inequality method returns 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.

Example

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.


//from ww  w  .ja v a  2  s .  co  m
using System;
public class MainClass{
  public static void Main(String[] argv){  
    // Create some Uris.
    Uri address1 = new Uri("http://www.java2s.com/index.htm#search");
    Uri address2 = new Uri("http://www.java2s.com/index.htm"); 
    Uri address3 = new Uri("http://www.java2s.com/index.htm?date=today"); 
    
    // The second two are not equal. 
    if (address2 != address3)
        Console.WriteLine("{0} is not equal to {1}", address2.ToString(), address3.ToString());

  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version