共用方式為


UriTemplateEquivalenceComparer.Equals(UriTemplate, UriTemplate) 方法

定義

比較兩個 UriTemplate 執行個體是否等價。

public:
 virtual bool Equals(UriTemplate ^ x, UriTemplate ^ y);
public bool Equals (UriTemplate x, UriTemplate y);
override this.Equals : UriTemplate * UriTemplate -> bool
Public Function Equals (x As UriTemplate, y As UriTemplate) As Boolean

參數

x
UriTemplate

UriTemplate 執行個體。

y
UriTemplate

UriTemplate 執行個體。

傳回

Boolean

指出兩個 UriTemplate 執行個體是否等價的值。

實作

範例

下列程式碼將示範如何呼叫 Equals 方法。

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

備註

通常不會直接呼叫這個方法, 而是由另一個比較兩個 UriTemplate 執行個體的類別呼叫。

適用於