✅ Covariant return type properties

Am I missing something - I thought that property return types could be covariant if they were readonly. So why does this not compile?
public abstract class C
{
public abstract object Prop { get; }
}

public class D : C
{
public override int Prop { get; }
}
public abstract class C
{
public abstract object Prop { get; }
}

public class D : C
{
public override int Prop { get; }
}
1 Reply
dreadfullydistinct
dreadfullydistinctOP3mo ago
Compiles if I do C and D or object and string - is it a restriction on value types? I see makes sense that it doesn’t support boxing Thanks
Want results from more Discord servers?
Add your server