Possible Duplicate:
Does C# support return type covariance?
I'm not sure if I'm just being stupid...
If I have an interface:
public interface IMoop
{
object Moop();
}
Why can't I implement it like so (I guess this would use implicit Covariance?)
public class MoopImplementor : IMoop
{
string Moop();
}
Any instance of MoopImplementor would meet the contract specified by IMoop, so it seems like this should be ok.
Please enlighten me :)
EDIT: To be clear- since the implementing class returns something that inherits from the return type of the Interfaced method - I feel this should work. Specifically, a string
IS an object
. (and the same goes for any other inhertiance chain).