N
Ning Hu
Hello,
I have a question on why I am getting an error of "Cannot implicitly
convert type 'testGenerics.testCollection' to
'testGenerics.IMyCollection<System.IComparable>'. An explicit
conversion exists (are you missing a cast?)" for the following code.
Since, a Double implements IComparable, It should be implicitly
castable no?
interface IMyCollection<myType> where myType : IComparable
{
}
class testCollection : IMyCollection<Double>
{
}
class Program
{
static void Main(string[] args)
{
IMyCollection<IComparable> test = new testCollection();
}
}
Thanks,
Ning
I have a question on why I am getting an error of "Cannot implicitly
convert type 'testGenerics.testCollection' to
'testGenerics.IMyCollection<System.IComparable>'. An explicit
conversion exists (are you missing a cast?)" for the following code.
Since, a Double implements IComparable, It should be implicitly
castable no?
interface IMyCollection<myType> where myType : IComparable
{
}
class testCollection : IMyCollection<Double>
{
}
class Program
{
static void Main(string[] args)
{
IMyCollection<IComparable> test = new testCollection();
}
}
Thanks,
Ning