using System.Data;
using System.Reflection;
DataTable dt = new DataTable();
var type = typeof(Customer);foreach (var info in type.GetProperties())
{
dt.Columns.Add(new DataColumn(info.Name, info.PropertyType));
}
try
{
for (int i = 0; i < CustomerOperator.customer.Length; i++)
{
DataRow dr = dt.NewRow();
foreach (PropertyInfo property in type.GetProperties())
{
dr[property.Name] = property.GetValue(CustomerOperator.customer[i], null);
}
dt.Rows.Add(dr);
}
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
throw new NotImplementedException();
}
finally
{
}