I have an objects like this
public class WEntity { string exStirng; public string EtcStirng { get { return exStirng; } set { exStirng = value; } } xEntity info; public xEntity Info { get { return info; } set { info = value; } } yEntity adress; public yEntity Adress { get { return adress; } set { adress = value; } } zEntity[] blala; public zEntity[] Blala { get { return blala; } set { blala = value; } } } I
am looking loop through all propertis in objects and add them as key value to my Item object.
for given object
key=exString value=exstringValue items.Add(item)
then
foreach (PropertyInfo pInfo in XEntity properties) { item = new Item(); item.Label = pInfo.Name; item.Value = pInfo.Value; items.Add(item); } foreach (PropertyInfo pInfo in YEntity properties) { item = new Item(); item.Label = pInfo.Name; item.Value = pInfo.Value; items.Add(item); } foreach(zEntity ent in blabla) { //Add all ent properties and values to Item Object }
What's the best way to do this?
kadirzade