H
Henk Bosman
Guest
As the title reads, I stumbled on something strange. The code below won't compile and gives an error. It doesn't like the "this" as input for "list.Add". The error reads "Error CS1503 Argument 1: cannot convert from 'Generics.MyClass' to 'T'". Can somebody tell me why this is creating an error? In my opinion it should work.
class MyClass : IMyInterface
{
public void Add<T>(List<T> list) where T : IMyInterface
{
list.Add(this);
}
}
Continue reading...
class MyClass : IMyInterface
{
public void Add<T>(List<T> list) where T : IMyInterface
{
list.Add(this);
}
}
Continue reading...