我已經創建像無法應用索引,以類型的表達式「T」
public void BindRecordSet<T>(IEnumerable<T> coll1, string propertyName)
where T : class
,並在我的課「T」我已經寫索引泛型方法
public object this[string propertyName]
{
get
{
Type t = typeof(SecUserFTSResult);
PropertyInfo pi = t.GetProperty(propertyName);
return pi.GetValue(this, null);
}
set
{
Type t = typeof(SecUserFTSResult);
PropertyInfo pi = t.GetProperty(propertyName);
pi.SetValue(this, value, null);
}
}
現在在我的方法,當我寫的代碼像
var result = ((T[])(coll1.Result))[0];
string result= secFTSResult[propertyName];
我收到錯誤 無法適用索引類型爲「T」
請幫 感謝
嗨BoltClock,BindRecordSet方法泛型類型的方法,在這裏T是BindRecordSet 其中學生是一類 –