Uredi

Deli z drugimi prek


ConstraintCollection.Item[] Property

Definition

Gets the specified Constraint from the collection.

Overloads

Item[Int32]

Gets the Constraint from the collection at the specified index.

Item[String]

Gets the Constraint from the collection with the specified name.

Item[Int32]

Source:
ConstraintCollection.cs
Source:
ConstraintCollection.cs
Source:
ConstraintCollection.cs

Gets the Constraint from the collection at the specified index.

public:
 property System::Data::Constraint ^ default[int] { System::Data::Constraint ^ get(int index); };
public:
 virtual property System::Data::Constraint ^ default[int] { System::Data::Constraint ^ get(int index); };
public System.Data.Constraint this[int index] { get; }
public virtual System.Data.Constraint this[int index] { get; }
member this.Item(int) : System.Data.Constraint
Default Public ReadOnly Property Item(index As Integer) As Constraint
Default Public Overridable ReadOnly Property Item(index As Integer) As Constraint

Parameters

index
Int32

The index of the constraint to return.

Property Value

The Constraint at the specified index.

Exceptions

The index value is greater than the number of items in the collection.

Examples

The following example gets each Constraint from the ConstraintCollection.

private void GetConstraint(DataTable table)
{
    for(int i = 0; i < table.Constraints.Count; i++)
    {
        Console.WriteLine(table.Constraints[i].ConstraintName);
        Console.WriteLine(table.Constraints[i].GetType());
    }
}
Private Sub GetConstraint(table As DataTable)
    Dim i As Integer
    For i = 0 To table.Constraints.Count - 1
        Console.WriteLine(table.Constraints(i).ConstraintName)
        Console.WriteLine(table.Constraints(i).GetType())
    Next i
 End Sub

Remarks

Use the Contains method to test for the existence of a specific constraint.

See also

Applies to

Item[String]

Source:
ConstraintCollection.cs
Source:
ConstraintCollection.cs
Source:
ConstraintCollection.cs

Gets the Constraint from the collection with the specified name.

public:
 property System::Data::Constraint ^ default[System::String ^] { System::Data::Constraint ^ get(System::String ^ name); };
public:
 virtual property System::Data::Constraint ^ default[System::String ^] { System::Data::Constraint ^ get(System::String ^ name); };
public System.Data.Constraint? this[string? name] { get; }
public System.Data.Constraint this[string name] { get; }
public virtual System.Data.Constraint this[string name] { get; }
member this.Item(string) : System.Data.Constraint
Default Public ReadOnly Property Item(name As String) As Constraint
Default Public Overridable ReadOnly Property Item(name As String) As Constraint

Parameters

name
String

The ConstraintName of the constraint to return.

Property Value

The Constraint with the specified name; otherwise a null value if the Constraint does not exist.

Examples

The following example gets the named Constraint.

private void GetConstraint(DataTable table)
{
    if(table.Constraints.Contains("CustomersOrdersConstraint"))
    {
        Constraint constraint =
            table.Constraints["CustomersOrdersConstraint"];
    }
}
Private Sub GetConstraint(table As DataTable)
    If table.Constraints.Contains("CustomersOrdersConstraint") Then
        Dim constraint As Constraint = _
            table.Constraints("CustomersOrdersConstraint")
    End If
End Sub

Remarks

Use the Contains method to test for the existence of a specific constraint.

Applies to