How can i access OtherAddress property in customer[0]
List<Orders> order = new List<Orders>();
Customer[] cs = { new Customer { CustNum = 5, OtherAddress = "Hello" }, new Customer { CustNum = 986, OtherAddress = "Other" } };
Customer[] cso = { new Customer { OtherAddress = "T", CustNum = 5 }, new Customer { CustNum = 777, OtherAddress = "other" } };
order.Add(new Orders(code + 1, "ALFKI", i + 0, 2.3 * i, "Mumbari", "Berlin", cs));
order.Add(new Orders(code + 2, "ANATR", i + 2, 3.3 * i, "Sydney", "Madrid", cso));
order.Add(new Orders(code + 3, "ANTON", i + 1, 4.3 * i, "NY", "Cholchester", cs));
order.Add(new Orders(code + 4, "BLONP", i + 3, 5.3 * i, "LA", "Marseille", cso));
order.Add(new Orders(code + 5, "BOLID", i + 4, 6.3 * i, "Cochin", "Tsawassen", cs));
To access the table operation complexData = "customer.0.OtherAddress".split('.'); type = typeof(orders);
PropertyInfo propInfo = type.GetProperty(complexData[0]);
for (var i = 1; i < complexData.Count(); i++)
{
propInfo = propInfo.PropertyType.GetProperty(complexData[i]);
}
return propInfo.PropertyType;
Aucun commentaire:
Enregistrer un commentaire