DataTableMappingCollection.IndexOf Método
Definición
Obtiene la ubicación del objeto DataTableMapping especificado en la colección.Gets the location of the specified DataTableMapping object within the collection.
Sobrecargas
IndexOf(Object) |
Obtiene la ubicación del objeto DataTableMapping especificado en la colección.Gets the location of the specified DataTableMapping object within the collection. |
IndexOf(String) |
Obtiene la ubicación del objeto DataTableMapping con el nombre de tabla de origen especificado.Gets the location of the DataTableMapping object with the specified source table name. |
IndexOf(Object)
Obtiene la ubicación del objeto DataTableMapping especificado en la colección.Gets the location of the specified DataTableMapping object within the collection.
public:
virtual int IndexOf(System::Object ^ value);
public int IndexOf (object? value);
public int IndexOf (object value);
abstract member IndexOf : obj -> int
override this.IndexOf : obj -> int
Public Function IndexOf (value As Object) As Integer
Parámetros
- value
- Object
Object que es el objeto DataTableMapping que se va a buscar.An Object that is the DataTableMapping object to find.
Devoluciones
Ubicación de base cero del objeto DataTableMapping especificado en la colección.The zero-based location of the specified DataTableMapping object within the collection.
Implementaciones
Ejemplos
En el siguiente ejemplo se busca un DataTableMapping dentro de la colección.The following example searches for a DataTableMapping within the collection. Si la asignación existe en la colección, se quita.If the mapping exists in the collection, it is removed. Si la asignación no existe en la colección, se agrega a la colección y se muestra su índice.If the mapping does not exist within the collection, it is added to the collection and its index is displayed. En el ejemplo se da por supuesto que DataTableMappingCollection se ha creado una colección y un DataTableMapping objeto.The example assumes that a DataTableMappingCollection collection and a DataTableMapping object have been created.
public void ChangedMyMind()
{
// ...
// create mappings and mapping
// ...
if (mappings.Contains((Object) mapping))
{
mappings.Remove((Object) mapping);
}
else
{
mappings.Add((Object) mapping);
Console.WriteLine("Index of new mapping: "
+ mappings.IndexOf((Object) mapping));
}
}
Public Sub ChangedMyMind()
' ...
' create mappings and mapping
' ...
If mappings.Contains(CType(mapping, Object)) Then
mappings.Remove(CType(mapping, Object))
Else
mappings.Add(CType(mapping, Object))
Console.WriteLine("Index of new mapping: " _
& mappings.IndexOf(CType(mapping, Object)).ToString())
End If
End Sub
Se aplica a
IndexOf(String)
Obtiene la ubicación del objeto DataTableMapping con el nombre de tabla de origen especificado.Gets the location of the DataTableMapping object with the specified source table name.
public:
virtual int IndexOf(System::String ^ sourceTable);
public int IndexOf (string? sourceTable);
public int IndexOf (string sourceTable);
abstract member IndexOf : string -> int
override this.IndexOf : string -> int
Public Function IndexOf (sourceTable As String) As Integer
Parámetros
- sourceTable
- String
Nombre, con distinción entre mayúsculas y minúsculas, de la tabla de origen.The case-sensitive name of the source table.
Devoluciones
Ubicación de base cero del objeto DataTableMapping con el nombre de tabla de origen especificado.The zero-based location of the DataTableMapping object with the specified source table name.
Implementaciones
Ejemplos
En el siguiente ejemplo se busca un DataTableMapping objeto con el nombre de tabla de origen especificado en una DataTableMappingCollection colección.The following example searches for a DataTableMapping object with the given source table name within a DataTableMappingCollection collection. Si DataTableMapping existe, el ejemplo muestra el nombre y el índice de la asignación.If the DataTableMapping exists, the example displays the name and the index of the mapping. Si la asignación no existe, en el ejemplo se muestra un error.If the mapping does not exist, the example displays an error. En este ejemplo se da por supuesto que se ha DataTableMappingCollection creado una colección.This example assumes that a DataTableMappingCollection collection has been created.
public void FindDataTableMapping()
{
// ...
// create mappings
// ...
if (!mappings.Contains("Categories"))
Console.WriteLine("Error: no such table in collection");
else
Console.WriteLine
("Name: " + mappings["Categories"].ToString() + "\n"
+ "Index: " + mappings.IndexOf("Categories").ToString());
}
Public Sub FindDataTableMapping()
' ...
' create mappings
' ...
If Not mappings.Contains("Categories") Then
Console.WriteLine("Error: no such table in collection")
Else
Console.WriteLine("Name: " & mappings("Categories").ToString() _
& ControlChars.Cr + "Index: " _
& mappings.IndexOf("Categories").ToString())
End If
End Sub