asp.net.ph

ConstraintCollection.IndexOf Method ( Constraint )

System.Data Namespace   ConstraintCollection Class


Returns the index of the specified Constraint.

[ VB ]
Overloads Protected Function IndexOf ( _
   ByVal constraint As Constraint _
) As Integer

[ C# ]
protected int IndexOf (
   Constraint constraint
);

[ C++ ]
protected: int IndexOf (
   Constraint* constraint
);

[ JScript ]
protected function IndexOf (
   constraint : Constraint
) : int

Parameters

constraint
The Constraint to search for.

Return Value

The index of the Constraint if it is in the collection; otherwise, -1.

Remarks

Use the IndexOf method to return an index to be used with either the Contains or Remove method.

Example

The following example uses the IndexOf method to return the index of a Constraint. The index is passed to the Contains method, before it is removed, to determine if the collection contains the constraint.

private void RemoveConstraint ( ConstraintCollection myConstraints, 
      Constraint myConstraint ) {
   try {
      if ( myConstraints.Contains ( myConstraint.ConstraintName ) ) {
         if ( myConstraints.CanRemove ( myConstraint ) ) {
            myConstraints.RemoveAt (
               myConstraints.IndexOf ( myConstraint.ConstraintName ) );
         }
      }
   }
   catch ( Exception myException ) {
      Response.Write ( myException.Message );
   }
}
  C# VB

See Also

ConstraintCollection Members   ConstraintCollection.IndexOf Overload List   Contains   Remove   CanRemove Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph