我爲InvalidCastException
問題嘗試投放的演員KeyValuePair在接口上
IList<KeyValuePair<string, object>> x
到
IList<IItem> y
其中的iItem是我的接口 我已經試過......
IList<IItem> y = (IItem) x; //INVALIDCASTEXCEPTION
IList<IItem> y = x.Cast<IItem>().ToList(); //another exception
...有人可以幫助我嗎?
什麼是 「_another EXCEPTION_」?從來沒有聽說過。你還應該顯示你的接口和一個實現它的類。 –
'IItem'是什麼類型?你能展示這個定義嗎? – codingbiz
'KeyValuePair'不是'IItem',你會期望你的演員怎麼做? – svick