UriTemplateEquivalenceComparer.Equals Method (UriTemplate, UriTemplate)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Compares two UriTemplate instances for equivalence.

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

public bool Equals(
	UriTemplate x,
	UriTemplate y
)

Parameters

x
Type: System.UriTemplate

A UriTemplate instance.

y
Type: System.UriTemplate

A UriTemplate instance.

Return Value

Type: System.Boolean

A value that indicates whether the two UriTemplate instances are equivalent.

This method is not normally called directly. It is called by another class that is comparing two UriTemplate instances.

The following code shows how to call the Equals method.

UriTemplate temp1 = new UriTemplate("weather/{state}/{city}");
UriTemplate temp2 = new UriTemplate("weather/{country}/{village}");

// Notice they are not reference equal, in other words
// they are do not refer to the same object
if (temp1 == temp2)
    Console.WriteLine("{0} and {1} are reference equal", temp1, temp2);
else
    Console.WriteLine("{0} and {1} are NOT reference equal", temp1, temp2);

// Notice they are structrually equal
UriTemplateEquivalenceComparer comparer = new UriTemplateEquivalenceComparer();
bool result = comparer.Equals(temp1, temp2);

if (result)
    Console.WriteLine("{0} and {1} are structurally equal", temp1, temp2);
else
    Console.WriteLine("{0} and {1} are NOT structurally equal", temp1, temp2);

.NET Framework
Available since 3.5
Return to top
Show: