共用方式為


UniqueConstraint.Equals(Object) 方法

定義

將這個條件約束和第二個條件約束相比較,以判斷兩者是否相同。

public:
 override bool Equals(System::Object ^ key2);
public override bool Equals (object? key2);
public override bool Equals (object key2);
override this.Equals : obj -> bool
Public Overrides Function Equals (key2 As Object) As Boolean

參數

key2
Object

這個 UniqueConstraint 所要比較的物件。

傳回

若兩個條件約束相等,則為 true;否則為 false

範例

下列範例會比較兩個 UniqueConstraint 物件。

Private Sub CompareConstraints()
    Dim constraintCustomerOrders As UniqueConstraint
    Dim constraintOrderDetails As UniqueConstraint
    Dim relationCustomerOrders As DataRelation
    Dim relationOrderDetails As DataRelation

    ' Get a DataRelation from a DataSet.
    relationCustomerOrders = DataSet1.Relations("CustomerOrders")

    '  Get a constraint.
    constraintCustomerOrders = relationCustomerOrders.ParentKeyConstraint

    ' Get a second relation and constraint.
    relationOrderDetails = DataSet1.Relations("OrderDetails")
    constraintOrderDetails = relationOrderDetails.ParentKeyConstraint

    ' Compare the two.
    Console.WriteLine( _
        constraintCustomerOrders.Equals(constraintOrderDetails).ToString())
 End Sub

備註

如果兩個條件約束限制相同的數據行,則兩個條件約束相等。

適用於

另請參閱