C# Uri Equals

Description

Uri Equals compares two Uri instances for equality.

Syntax

Uri.Equals has the following syntax.


[SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
public override bool Equals(
  Object comparand
)

Parameters

Uri.Equals has the following parameters.

  • comparand - The Uri instance or a URI identifier to compare with the current instance.

Returns

Uri.Equals method returns A Boolean value that is true if the two instances represent the same URI; otherwise, false.

Example

This example creates two Uri instances from strings and compares them to determine whether they represent the same value.


//from w w w.  ja v  a2  s .c om
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"); 
    if (address1.Equals(address2))
        Console.WriteLine("The two addresses are equal");
    else
        Console.WriteLine("The two addresses are not equal");

  }
}
    

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