DataColumnMappingCollection 构造函数

定义

创建一个空的 DataColumnMappingCollection

public:
 DataColumnMappingCollection();
public DataColumnMappingCollection ();
Public Sub New ()

示例

以下示例创建一个 DataColumnMappingCollection 集合,将对象添加到 DataColumnMapping 集合,并显示映射的源列的列表。

public void CreateColumnMappings()
{
    DataColumnMappingCollection mappings =
        new DataColumnMappingCollection();
    mappings.Add("Category Name","DataCategory");
    mappings.Add("Description","DataDescription");
    mappings.Add("Picture","DataPicture");
    string myMessage = "ColumnMappings:\n";
    for(int i=0;i < mappings.Count;i++)
    {
        myMessage += i.ToString() + " "
            + mappings[i].ToString() + "\n";
    }
    Console.WriteLine(myMessage);
}
Public Sub CreateColumnMappings()
    Dim mappings As New DataColumnMappingCollection()
    mappings.Add("Category Name", "DataCategory")
    mappings.Add("Description", "DataDescription")
    mappings.Add("Picture", "DataPicture")
    Dim myMessage As String = "ColumnMappings:" + ControlChars.Cr
    Dim i As Integer
    For i = 0 To mappings.Count - 1
        myMessage += i.ToString() + " " + mappings(i).ToString() _
           + ControlChars.Cr
    Next i
    Console.WriteLine(myMessage)
End Sub

适用于

另请参阅