ConstraintCollection.Contains(String) 메서드

정의

이름으로 지정된 개체가 Constraint 컬렉션에 있는지 여부를 나타냅니다.

public:
 bool Contains(System::String ^ name);
public bool Contains(string? name);
public bool Contains(string name);
member this.Contains : string -> bool
Public Function Contains (name As String) As Boolean

매개 변수

name
String

ConstraintName 제약 조건의 수입니다.

반품

true컬렉션에 지정된 제약 조건이 포함되어 있으면 이고, 그렇지 않으면 . false

예제

다음 예제에서는 지정된 Constraint 값이 삭제 전의 ConstraintCollection 위치에 있는지 여부를 확인합니다.

public static void RemoveConstraint(
    ConstraintCollection constraints, Constraint constraint)
{
    try
    {
        if(constraints.Contains(constraint.ConstraintName))
        {
            if(constraints.CanRemove(constraint))
            {
                constraints.Remove(constraint.ConstraintName);
            }
        }
    }
    catch(Exception e)
    {
        // Process exception and return.
        Console.WriteLine("Exception of type {0} occurred.",
            e.GetType());
    }
}
Public Shared Sub RemoveConstraint( _
    constraints As ConstraintCollection, constraint As Constraint)
    Try
        If constraints.Contains(constraint.ConstraintName) Then
            If constraints.CanRemove(constraint)
                constraints.Remove(constraint.ConstraintName)
            End If
        End If

    Catch e As Exception
        ' Process exception and return.
        Console.WriteLine($"Exception of type {e.GetType()} occurred.")
    End Try
 End Sub

설명

Contains 컬렉션에서 제거하기 전에 지정된 Constraint 항목이 있는지 여부를 확인하려면 이 메서드를 사용합니다. 이 메서드를 CanRemove 사용하여 제거할 수 있는지 여부를 Constraint 확인할 수도 있습니다.

적용 대상

추가 정보