Generic class implementing interface fails
Posted
by Pitming
on Stack Overflow
See other posts from Stack Overflow
or by Pitming
Published on 2010-04-22T08:19:55Z
Indexed on
2010/04/22
8:23 UTC
Read the original article
Hit count: 150
c#
A meet a strange problem at compimation saying that a class does not implement an interface.
Lets say a v got a class:
public Class MyClass
{
...
}
And an interace:
public Interface IMyInterface
{
MyClass PropertyOfMyClass {get;}
}
and now a generic class:
public class MyGeneric<T> where T:MyClass
{
T PropertyOfMyClass
{
get{return ...;}
}
}
Until here everythings fine and compiles right.
But this will break at compilation time:
public class MyGeneric<T>:IMyInterace where T:MyClass
{
T PropertyOfMyClass
{
get{return ...;}
}
}
Saying that MyGeneric does not implements method of IMyInterface. But obviously it does, not ?
© Stack Overflow or respective owner