Fixed: IList <T> for a custom class that implements ICollection <T>
This is my custom collection ad.
public interface IMenuCollection<T> : ICollection<T>
public class HTMLMenuCollection: IMenuCollection<HTMLMenu>
I am trying to transfer it from another collection IList<T>.
IList<HTMLMenu> htmlMenuList = new List<HTMLMenu>();
...
HTMLMenuCollection tempColl = (HTMLMenuCollection)htmlMenuList;
I have no idea why this will not work. If I drop IList<T>in ICollection<T>, it works fine, but with this I get an invalid lit exception. What am I doing wrong?
+3
5 answers