I\'ve got an IList that I want to cast to ICollection but when I attempt an explicit cast, I get null
I don't think it's possible, and indeed it shouldn't be:
class BaseClass {}
class DerivedClass : BaseClass {}
class OtherClass : BaseClass {}
void test()
{
List list = new List();
slice(list); //you want to do this
}
void slice(IList list)
{
//yikes! adding OtherClass to List
list.Add(new OtherClass());
}