DataColumnMappingCollection.IndexOf Método

Definição

Obtém o local do DataColumnMapping especificado na coleção.Gets the location of the specified DataColumnMapping within the collection.

Sobrecargas

IndexOf(String)

Obtém o local do DataColumnMapping com o nome da coluna de origem especificado.Gets the location of the DataColumnMapping with the specified source column name.

IndexOf(Object)

Obtém o local do Object especificado que é um DataColumnMapping na coleção.Gets the location of the specified Object that is a DataColumnMapping within the collection.

IndexOf(String)

Obtém o local do DataColumnMapping com o nome da coluna de origem especificado.Gets the location of the DataColumnMapping with the specified source column name.

public:
 virtual int IndexOf(System::String ^ sourceColumn);
public int IndexOf (string? sourceColumn);
public int IndexOf (string sourceColumn);
abstract member IndexOf : string -> int
override this.IndexOf : string -> int
Public Function IndexOf (sourceColumn As String) As Integer

Parâmetros

sourceColumn
String

O nome que diferencia maiúsculas de minúsculas da coluna de origem.The case-sensitive name of the source column.

Retornos

Int32

O local com base em zero do DataColumnMapping com o nome da coluna de origem especificado que diferencia maiúsculas de minúsculas.The zero-based location of the DataColumnMapping with the specified case-sensitive source column name.

Implementações

Exemplos

O exemplo a seguir pesquisa um DataColumnMapping objeto com o nome de coluna de origem fornecido dentro de uma DataColumnMappingCollection coleção.The following example searches for a DataColumnMapping object with the given source column name within a DataColumnMappingCollection collection. Se o DataColumnMapping existir, o exemplo exibirá o nome e o índice do mapeamento.If the DataColumnMapping exists, the example displays the name and the index of the mapping. Se o mapeamento não existir, o exemplo exibirá um erro.If the mapping does not exist, the example displays an error. Este exemplo supõe que uma DataColumnMappingCollection coleção foi criada.This example assumes that a DataColumnMappingCollection collection has been created.

public void FindDataColumnMapping()
{
    // ...
    // create columnMappings
    // ...
    if (!columnMappings.Contains("Description"))
    {
        Console.WriteLine("Error: no such table in collection.");
    }
    else
    {
        Console.WriteLine("Name {0}",
            columnMappings["Description"].ToString());
        Console.WriteLine("Index: {0}",
            columnMappings.IndexOf("Description").ToString());
    }
}
Public Sub FindDataColumnMapping()
    ' ...
    ' create columnMappings
    ' ...
    If Not columnMappings.Contains("Description") Then
        Console.WriteLine("Error: no such table in collection.")
    Else
       Console.WriteLine("Name: {0}", _
           columnMappings("Description").ToString())
       Console.WriteLine("Index: {0}", _
           columnMappings.IndexOf("Description").ToString())
    End If
End Sub

Aplica-se a

IndexOf(Object)

Obtém o local do Object especificado que é um DataColumnMapping na coleção.Gets the location of the specified Object that is a DataColumnMapping 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

Um Object que é o DataColumnMapping a ser localizado.An Object that is the DataColumnMapping to find.

Retornos

Int32

O local com base em zero do Object especificado que é um DataColumnMapping na coleção.The zero-based location of the specified Object that is a DataColumnMapping within the collection.

Implementações

Exemplos

O exemplo a seguir pesquisa um DataColumnMapping dentro da coleção.The following example searches for a DataColumnMapping within the collection. Se o mapeamento existir na coleção, ele será removido.If the mapping exists in the collection, it is removed. Se o mapeamento não existir na coleção, ele será adicionado à coleção e seu índice será exibido.If the mapping does not exist within the collection, it is added to the collection and its index is displayed. O exemplo supõe que uma DataColumnMappingCollection coleção e um DataColumnMapping objeto foram criados.The example assumes that a DataColumnMappingCollection collection and a DataColumnMapping 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

Aplica-se a