ExpandoObject (edit)
Tìm kiếm thư viện hỗ trợ trên NuGet
Sample 1
dynamic contact = new ExpandoObject();
contact.Name = "Patrick Hines";
contact.Phone = "206-555-0144";
contact.Address = new ExpandoObject();
contact.Address.Street = "123 Main St";
contact.Address.City = "Mercer Island";
contact.Address.State = "WA";
contact.Address.Postal = "68402";
Sample 2
var records = new List<dynamic>();
dynamic record = new ExpandoObject();
record.Id = 1;
record.Name = "one";
records.Add(record);
using (var writer = new StringWriter())
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteRecords(records);
var s = writer.ToString();
Console.WriteLine(s);
}