Lets say I have the following class:
public class Provider
{
...
public sealed class Slice
{
public readonly double firstName;
public readonly double secondName;
public readonly double thirdName;
...
}
...
}
This class is used to hold a sliding time series and the contained Slice class is the return value. (Provider.Last property returns the latest instance of Slice).
I need to get the value of the properties of that latest returned Slice class by name of the property.
PropertyInfo secondNameProperty = Provider.Last.GetType().GetProperty("secondName");
double secondNameValue = (double)secondNameProperty.GetValue(Provider.Last, null);
GetProperty returns null. How can I do this?