ConstraintCollection.Item[] Propriedade
Definição
Obtém o Constraint especificado na coleção.Gets the specified Constraint from the collection.
Sobrecargas
| Item[Int32] |
Obtém o Constraint da coleção no índice especificado.Gets the Constraint from the collection at the specified index. |
| Item[String] |
Obtém o Constraint da coleção com o nome especificado.Gets the Constraint from the collection with the specified name. |
Item[Int32]
Obtém o Constraint da coleção no índice especificado.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
Parâmetros
- index
- Int32
O índice da restrição a ser retornado.The index of the constraint to return.
Valor da propriedade
O Constraint no índice especificado.The Constraint at the specified index.
Exceções
O valor de índice é maior que o número de itens na coleção.The index value is greater than the number of items in the collection.
Exemplos
O exemplo a seguir obtém cada um Constraint do ConstraintCollection .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
Comentários
Use o Contains método para testar a existência de uma restrição específica.Use the Contains method to test for the existence of a specific constraint.
Confira também
Aplica-se a
Item[String]
Obtém o Constraint da coleção com o nome especificado.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
Parâmetros
- name
- String
O ConstraintName da restrição a ser retornado.The ConstraintName of the constraint to return.
Valor da propriedade
O Constraint com o nome especificado; caso contrário, um valor nulo se o não Constraint existir.The Constraint with the specified name; otherwise a null value if the Constraint does not exist.
Exemplos
O exemplo a seguir obtém o nome Constraint .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
Comentários
Use o Contains método para testar a existência de uma restrição específica.Use the Contains method to test for the existence of a specific constraint.