When we declare a parameter as ICollection and instantiated the object as List, why we can't retrive the indexes? i.e.
ICollection<ProductDTO> Products = new List<ProductDTO>();
Products.Add(new ProductDTO(1,"Pen"));
Products.Add(new ProductDTO(2,"Notebook"));
Then, this will not work:
ProductDTO product = (ProductDTO)Products[0];
What is the bit I am missing?
[Yes, we can use List as declaration an it can work, but I don't want to declare as list, like:
List<ProductDTO> Products = new List<ProductDTO>();
]