DataColumnMappingCollection.IndexOf 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得集合中指定 DataColumnMapping 位置。
多載
| 名稱 | Description |
|---|---|
| IndexOf(String) |
取得 的位置 DataColumnMapping ,並取得指定的來源欄位名稱。 |
| IndexOf(Object) |
取得集合中指定ObjectDataColumnMapping位置。 |
IndexOf(String)
取得 的位置 DataColumnMapping ,並取得指定的來源欄位名稱。
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
參數
- sourceColumn
- String
來源欄位的大小寫區分名稱。
傳回
以零為基礎的位置 DataColumnMapping ,並指定大小寫區分來源欄位名稱。
實作
範例
以下範例是在 DataColumnMapping 集合中 DataColumnMappingCollection 搜尋具有給定來源欄位名稱的物件。 若存在, DataColumnMapping 範例會顯示映射的名稱與索引。 若該映射不存在,範例會顯示錯誤。 此範例假設已建立一個 DataColumnMappingCollection 集合。
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
另請參閱
適用於
IndexOf(Object)
取得集合中指定ObjectDataColumnMapping位置。
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
參數
- value
- Object
Object那就是DataColumnMapping要找到的。
傳回
指定 Object 的零基位置 在集合中為 a DataColumnMapping 。
實作
範例
以下範例是在集合中搜尋 a DataColumnMapping 。 如果該映射存在於集合中,則會將其移除。 若該映射不存在於集合中,則會將其加入集合並顯示其索引。 本範例假設已建立一個 DataColumnMappingCollection 集合與一個 DataColumnMapping 物件。
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