UriTemplateEquivalenceComparer.Equals(UriTemplate, UriTemplate) Method

Definition

Compares two UriTemplate instances for equivalence.

C#
public bool Equals(UriTemplate x, UriTemplate y);

Parameters

x
UriTemplate

A UriTemplate instance.

y
UriTemplate

A UriTemplate instance.

Returns

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

Implements

Examples

The following code shows how to call the Equals method.

C#
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);

Remarks

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

Applies to

Product Versions
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1