A
Ashish
Hi all,
I have interface declared like
public IBaseInterface
{
}
then a generic collection like
public GCollection<T> Where T:IBaseInterface
{
}
then i have a class like
public class Address:IBaseInterface
{}
so i declare a collection of Address type
GCollection<Address> mcol = new GCollection<Address>();
then i try to type cast it to
GCollection<IBaseInterface> mysecondcol = (GCollection<IBaseInterface>)
mcol; // this throws type cast exception !
can someone explain why this is not allowed and what can be a way around ?
TIA
I have interface declared like
public IBaseInterface
{
}
then a generic collection like
public GCollection<T> Where T:IBaseInterface
{
}
then i have a class like
public class Address:IBaseInterface
{}
so i declare a collection of Address type
GCollection<Address> mcol = new GCollection<Address>();
then i try to type cast it to
GCollection<IBaseInterface> mysecondcol = (GCollection<IBaseInterface>)
mcol; // this throws type cast exception !
can someone explain why this is not allowed and what can be a way around ?
TIA