paint-brush
Hiding Members via Explicit Interface Implementation in C#by@lee-mcgraw
5,224 reads
5,224 reads

Hiding Members via Explicit Interface Implementation in C#

by Lee McGraw6mSeptember 10th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Explicit Interface Implementation is a complex and rarely used technique that allows a single class to inherit from multiple interfaces that have the same method signature. The technique can be used to hide members from being accessed via the class reference. This is a simple example of this technique using a factory design pattern and Fruit class and a console application that you can step through via F11. The interface IFruit is hidden to the client, being private, and is only accessible from within the factory’s create method. This allows me to get a red Apple, a yellow Banana, and orange Orange.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Hiding Members via Explicit Interface Implementation in C#
Lee McGraw HackerNoon profile picture
Lee McGraw

Lee McGraw

@lee-mcgraw

Www.linkedin.com/in/rleemcgraw

About @lee-mcgraw
LEARN MORE ABOUT @LEE-MCGRAW'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Lee McGraw HackerNoon profile picture
Lee McGraw@lee-mcgraw
Www.linkedin.com/in/rleemcgraw

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Coffee-web
In