I know, I have other options, e.g. I could maintain a separate list of keys. Please don\'t suggest other options. I simply want to know if I can pull this off. Please don\'t
Your foreach loop will throw an InvalidCastException if the Keys collection doesn't contain an int.
foreach
InvalidCastException
Keys
int
The cast to List fails because the compiler can't convert a non-generic ICollection to a specific ICollection
List
ICollection