Я пытаюсь использовать PropertyInfo для взаимодействия через класс и создания данных из него.Однако он не возвращает значений.Я немного озадачен;
public class thetransactions
{
public string FirstName;
public string Surname;
public string PreviousOwner;
public string NewOwner;
public string postcode;
public string[] FileName;
}
Тогда сделайте работу с этим кодом;
theTransactions[] thetransactions = new theTransactions[10];
thetransactions[0] = JsonConvert.DeserializeObject<theTransactions>(mydatastring);
PropertyInfo[] properties = thetransactions.GetType().GetElementType().GetProperties();
DataTable sampletable = new DataTable();
DataColumn dc = null;
foreach (PropertyInfo pi in properties)
{
dc = new DataColumn();
dc.ColumnName = pi.Name;
dc.DataType = pi.PropertyType;
sampletable.Columns.Add(dc);
}