Dynamische Objekte erstellen

Wie erstelle ich dynamisch Objekte?

string[] columnNames = { "EmpName", "EmpID", "PhoneNo" };
List<string[]> columnValues = new List<string[]>();
for (int i = 0; i < 10; i++)
{
    columnValues.Add(new[] { "Ramesh", "12345", "12345" });
}

List<Dictionary<string, object>> testData = new List<Dictionary<string, object>>();

foreach (string[] columnValue in columnValues)
{
    Dictionary<string, object> data = new Dictionary<string, object>();
    for (int j = 0; j < columnNames.Count(); j++)
    {
        data.Add(columnNames[j], columnValues[j]);
    }
    testData.Add(data);
}

Imaginäre Klasse (Klasse ist im Code nicht verfügbar):

class Employee
{
    string EmpName { get;set; }
    string EmpID { get;set; }
    string PhoneNo { get;set; }
}

Hinweis: Eigenschafts- / Spaltennamen sind dynamisch.

Jetzt möchte ich die konvertierenList<Dictionary<string, object>> zu einer Klasse von TypList<object> (d. h.)List<Employee>.

Ist es möglich? Vorschläge bitte.

Antworten auf die Frage(3)

Ihre Antwort auf die Frage