jeudi 23 novembre 2017

C# Reflection: Cannot convert type 'System.Reflection.PropertyInfo' to

Morning,

I am trying to use reflection to iterate all properties in one of my classes :

public MDInstrument() : base()
    {
        PropertyInfo[] properties = typeof(MDInstrument).GetProperties();

        foreach (PropertyInfo item in properties)
        {
            var tick = item as TickData;
        }
    }

when I inspect the var properties I can see all the properties correctly

enter image description here

but on the line:

 var tick = item as TickData;

I am getting the error:

enter image description here





Aucun commentaire:

Enregistrer un commentaire