本文介绍了如何投放的IList要ArrayList的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以投的IList 的ArrayList



如果是我应该怎么办

  IList的承滴盘= RetrieveCourseStudents(CF)?; 
ArrayList的一个=(ArrayList的)承滴盘;



这是否正确?



是有错误:



解决方案

This is all about polymorphism.ArrayList is an implementation from the Interface IList.

 IList iList = new ArrayList();  

The static type from the variable iList is IList but it references an ArrayList Object!

There is no real casting from IList to ArrayList because you can not instantiate/create Object from Interface or abstract Class.

这篇关于如何投放的IList要ArrayList的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:12