我有一个像下面这样的结构。我在返回通用集合时遇到了一些麻烦。我错过了什么?
class Program
{
static void Main()
{
BusinessCollection businessCollection = new BusinessCollection();
//Why this is not working because businesscollection is a GenericCollection<BusinessEntity>
businessCollection = new GenericCollection<BusinessEntity>();
//or neither this
businessCollection = (BusinessCollection)new GenericCollection<BusinessEntity>();
}
}
public class BusinessEntity
{
public string Foo { get; set;}
}
public class BusinessCollection : GenericCollection<BusinessEntity>
{
//some implementation here
}
public class GenericCollection<T> : ICollection<T>
{
//some implementation here
}