Home > Mobile >  How does "Implement interface through <field>" work?
How does "Implement interface through <field>" work?

Time:04-09

I'm wondering how the "Implement interface through [field]" thing works with Intellisense, is it something that's just hard-coded into Intellisense for specific interfaces, or is it done dynamically? If so, is there a way I can get it to do the same thing with my own interfaces?

Note: I looked through many similar questions, and I think that by now it's safe to assume that nobody has asked the question I'm trying to ask. I also cannot think of any ways to make it any less ambiguous.

CodePudding user response:

That feature is pretty straightforward. If you have a class that meets these criteria:

  • claims to implement an interface
  • isn't implementing the members required by that interface
  • has a field or a property which does implement that interface

... then this code analysis recommendation will allow you to create implementations for the missing members which simply pass through to the same members on the given field or property.

You can absolutely make it work on your own interface, by meeting the aforementioned criteria.

before

after

  • Related