Allow Overrides and Implicit Interface Implementations to Override/Implement using Generically-Typed, Constrained members #4113
Unanswered
fitdev
asked this question in
Language Ideas
Replies: 1 comment 3 replies
-
What happens if someone does this: public class Foo1 : IFoo { }
public class Foo2 : IFoo { }
ClassBase c = new ClassGenericDerived<Foo1>();
c.Foo = new Foo2(); The signature of |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It would be nice if we could write code like this where generically-typed members (with appropriate constraints) can override members in the base class:
In the above code
T
is guaranteed to be of typeIFoo
due to generic constraint. So, why can'tT Foo {get; set; }
override base class memberpublic virtual IFoo Foo { get; set; }
?Same logic would go for implicit interface implementations.
Beta Was this translation helpful? Give feedback.
All reactions