可能重複:
How to iterate the List in Reflection
Problem with IEnumerable in Reflection問題與IEnumerable的反思性
嗨,
我在迭代反射列表面臨的一個問題。
var item = property.GetValue(obj,null); // We dont know the type of obj as it is in Reflection.
foreach(var value in (item as IEnumerable))
{
//Do stuff
}
如果我這樣做,我會得到這樣的
錯誤使用泛型類型「System.Collections.Generic.IEnumerable」需要1個類型參數
請幫助我。
你需要投到'IEnumerable'不IEnumerable –
Stecya
2011-05-10 13:15:51