Interface referencing another interface but class referencing another class in C# -
i have simple question, haven't had problem before.
take @ code:
interface ifoo { ibar mybar { get; } } interface ibar { string test { get; } } class foo : ifoo { public bar mybar { get; set; } } class bar : ibar { public string test { get; set; } } the problem foo doesn't implement ifoo since returns bar rather ibar. don't see problem since bar implementing ibar. miss something?
i want application use class foo expose ifoo other parts of solution.
this way around it, seems ugly solution:
class foo : ifoo { public bar mybar { get; set; } ibar ifoo.mybar { { return this.mybar; } } } is way go, or better way?
you can this:
interface ifoo<out b> b:ibar { b mybar { get; } } interface ibar { string test { get; } } class foo : ifoo<bar> { public bar mybar { get; set; } } class bar : ibar { public string test { get; set; } } this work in case b in output position (for obvious reasons, if think long enough).
Comments
Post a Comment