Delegate.Equality(Delegate, Delegate) 運算子
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷指定的委派是否相等。
public:
static bool operator ==(Delegate ^ d1, Delegate ^ d2);
public static bool operator ==(Delegate d1, Delegate d2);
public static bool operator ==(Delegate? d1, Delegate? d2);
static member ( = ) : Delegate * Delegate -> bool
Public Shared Operator == (d1 As Delegate, d2 As Delegate) As Boolean
- d1
- Delegate
要比較的第一個委派。
- d2
- Delegate
要比較的第二個委派。
如果 true
等於 d1
,則為 d2
,否則為 false
。
具有相同目標、方法和調用清單之相同類型的兩個委派會被視為相等。
如果兩個委派的類型不相同,則不會視為相等。
方法與目標會比較是否相等,如下所示:
如果比較的兩種方法都是靜態的,而且在相同的類別上是相同的方法,則會將方法視為相等,而且目標也會被視為相等。
如果比較的兩種方法是實例方法,而且在相同的物件上是相同的方法,則會將方法視為相等,而且目標也會視為相等。
否則,方法不會被視為相等,而且不會將目標視為相等。
如果兩個叫用清單的順序相同,且來自兩個清單的對應元素代表相同的方法和目標,則會將兩個叫用清單視為相同。
這個運算子的對等方法為 Delegate.Equals(Object)
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 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 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |