jeudi 28 juin 2018

Get Properties of Dynamic Object

I tried using reflection as suggested as the answer here, but nothing is returned. Here's my code:

for (int x = ro.records.Count - 1; x >= 0; x--)
{
    dynamic foundObject;
    if (outputList.TryGetValue(ro.records[x].Id, out foundObject))
    {
        string s = ro.records[x].Id; //THIS CONTAINS A VALUE
        PropertyInfo[] props = ((object)ro.records[x]).GetType().GetProperties(); //THIS FINDS 0 PROPERTIES
        foreach(PropertyInfo pi in props)
        {
            //Do stuff
        }
    }
}

As my comments in the code state, I can get the "Id" property, but my PropertyInfo[] array is always empty. I'm stumped.





Aucun commentaire:

Enregistrer un commentaire