ConstraintCollection.IndexOf Yöntem

Tanım

Belirtilen Constraintöğesinin dizinini alır.

Aşırı Yüklemeler

Name Description
IndexOf(Constraint)

Belirtilen Constraintöğesinin dizinini alır.

IndexOf(String)

Ada göre belirtilen Constraint dizinini alır.

IndexOf(Constraint)

Kaynak:
ConstraintCollection.cs
Kaynak:
ConstraintCollection.cs
Kaynak:
ConstraintCollection.cs
Kaynak:
ConstraintCollection.cs
Kaynak:
ConstraintCollection.cs

Belirtilen Constraintöğesinin dizinini alır.

public:
 int IndexOf(System::Data::Constraint ^ constraint);
public int IndexOf(System.Data.Constraint? constraint);
public int IndexOf(System.Data.Constraint constraint);
member this.IndexOf : System.Data.Constraint -> int
Public Function IndexOf (constraint As Constraint) As Integer

Parametreler

constraint
Constraint

Constraint Aranacak.

Döndürülenler

Koleksiyondaysa sıfır tabanlı dizini Constraint ; aksi takdirde -1.

Örnekler

Aşağıdaki örnek, IndexOf bir Constraintdizinini döndürmek için yöntemini kullanır. Dizin, kaldırılmadan önce yöntemine Contains geçirilir ve koleksiyonun kısıtlamayı içerip içermediğini belirler.

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

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

Açıklamalar

IndexOf veya Contains yöntemiyle Remove kullanılacak dizini döndürmek için yöntemini kullanın.

Ayrıca bkz.

Şunlara uygulanır

IndexOf(String)

Kaynak:
ConstraintCollection.cs
Kaynak:
ConstraintCollection.cs
Kaynak:
ConstraintCollection.cs
Kaynak:
ConstraintCollection.cs
Kaynak:
ConstraintCollection.cs

Ada göre belirtilen Constraint dizinini alır.

public:
 int IndexOf(System::String ^ constraintName);
public:
 virtual int IndexOf(System::String ^ constraintName);
public int IndexOf(string? constraintName);
public int IndexOf(string constraintName);
public virtual int IndexOf(string constraintName);
member this.IndexOf : string -> int
abstract member IndexOf : string -> int
override this.IndexOf : string -> int
Public Function IndexOf (constraintName As String) As Integer
Public Overridable Function IndexOf (constraintName As String) As Integer

Parametreler

constraintName
String

öğesinin Constraintadı.

Döndürülenler

Koleksiyonun Constraint içindeyse dizini; aksi takdirde -1.

Örnekler

Aşağıdaki örnek, IndexOf bir Constraintdizinini döndürmek için yöntemini kullanır. Dizin, koleksiyonu kaldırmadan önce kısıtlamayı içerip içermediğini belirlemek için yöntemine geçirilir Contains .

private void RemoveConstraint(
    ConstraintCollection constraints, Constraint constraint)
{
    try
    {
        if(constraints.Contains(constraint.ConstraintName))
        {
            if(constraints.CanRemove(constraint))
            {
                constraints.RemoveAt(
                    constraints.IndexOf(constraint.ConstraintName));
            }
        }
    }
    catch(Exception e)
    {
        // Process exception and return.
        Console.WriteLine("Exception of type {0} occurred.",
            e.GetType());
    }
}
Private Sub RemoveConstraint _
    (constraints As ConstraintCollection, constraint As Constraint)

    Try
        If constraints.Contains(constraint.ConstraintName) Then
            If constraints.CanRemove(constraint) Then
                constraints.RemoveAt _
                (constraints.IndexOf(constraint.ConstraintName))
            End If
        End If

    Catch ex As Exception
    ' Process exception and return.
        Console.WriteLine(ex.Message)
    End Try
End Sub

Açıklamalar

IndexOf veya Contains yöntemiyle Remove kullanılacak dizini döndürmek için yöntemini kullanın.

Ayrıca bkz.

Şunlara uygulanır