ConstraintCollection.Item[] Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the specified Constraint from the collection.
Item[Int32] |
Gets the Constraint from the collection at the specified index. |
Item[String] |
Gets the Constraint from the collection with the specified name. |
- 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
.NET 9 and other versions
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
- 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
.NET 9 and other versions
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: