Can I Cast IList into ArrayList?
if yes what should I do?
IList alls = RetrieveCourseStudents(cf);
ArrayList a = (ArrayList)alls;
Is that correct?
is has error:
Unable to cast object of type
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is all about polymorphism.
ArrayList is an implementation from the Interface IList.
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.