我想通過反射的PropertyInfo.GetValue()
方法,其中包含一個對象下面的類的一個檢索返回對象的值:如何動態地將對象轉換爲UnderlyingSystemType類?
Class NDataSeriesDouble: NDataSeries<double>
{}
Class NDataSeriesString: NDataSeries<string>
{}
//代碼在運行時獲取列表值
GetNthValueOfSereis(int n)
{
NHitTestResult hitTestResult = chartControl.HitTest(mouseXPoint, mouseYPoint)
// Get the sereis type object from Base class of this.
Type seriesType = hitTestResult.Series.GetType();
object seriesValues= seriesType.GetProperty("Values")
.GetValue(hitTestResult.Series, null)
**///How i get value from this object seriesValues**
}
seriesValues對象包含NDataSeriesDouble或NDataSeriesString類對象。
任何建議將不勝感激。
在此先感謝。
下來選民照顧評論。 – 2012-03-22 12:52:28
我想象誰投票是這樣做的,因爲這是一個寫得不好或格式不清的問題。 – Ian 2012-03-22 15:45:02
這個庫不是由我創建的..所以我不知道有多少類型的系列可用。 – 2012-03-23 06:09:10