Item Property (Int32)
Collapse the table of content
Expand the table of content

ConstraintCollection.Item Property (Int32)

 

Gets the Constraint from the collection at the specified index.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

public Constraint this[
	int index
] { get; }

Parameters

index
Type: System.Int32

The index of the constraint to return.

Property Value

Type: System.Data.Constraint

The Constraint at the specified index.

Exception Condition
IndexOutOfRangeException

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

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

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());
    }
}

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft