Created
July 12, 2011 03:58
-
-
Save vasily-kirichenko/1077367 to your computer and use it in GitHub Desktop.
Interfaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var anotherClass = new AnotherClass(); | |
| var worker = new Worker(anotherClass); | |
| worker.DoWork(); | |
| class Worker | |
| { | |
| private readonly WorkListener _listener; | |
| public Worker(WorkListener listener) | |
| { | |
| if (listener == null) | |
| throw new ArgumentNullException("listener"); | |
| _listener = listener; | |
| } | |
| public void DoWork() | |
| { | |
| //.. | |
| _listener.WorkDone(); | |
| } | |
| } | |
| interface WorkListener | |
| { | |
| void WorkDone(); | |
| } | |
| class AnotherClass : WorkListener | |
| { | |
| void WorkListener.WorkDone() | |
| { | |
| //.. | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment