jeudi 12 septembre 2019

How to Get a Double object's Value using Reflection in C#?

I have a nested class that I am navigating to parse a double object

In debugger I can see the object's value is a number

However I cannot simply cast and add it to a list this way,

values.Add((double)current_object);

Because of a System.InvalidCastException: 'Specified cast is not valid.' exception

How can I retrieve the double object's Value using reflection?

This is what I tried so far:

current_object.GetType().GetProperty("Value").GetValue(current_object) but current_object.GetType().GetProperty("Value") returns null

Thank you





Aucun commentaire:

Enregistrer un commentaire