Created
February 14, 2013 19:22
-
-
Save gsscoder/4955513 to your computer and use it in GitHub Desktop.
C# wish list: Partial Implementation of Interfaces
This file contains 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
/* | |
for C# wish list | |
---------------- | |
partial implementation of interface while coding | |
(something can be done with DynamicMethod, IL generation | |
but I'd like a language feature) | |
*/ | |
interface IMyInterface { | |
int DoOperation1(); | |
string DoOperation2(); | |
void DoOperation3(); | |
} | |
class ConsumerOfMyInterface { | |
public void Consume(IMyInterface value) { // ... | |
} | |
} | |
var partialImpl = new<IMyInterface> { | |
DoOperation2() => return "hello, partial impl!"; | |
//other method -> default empty stub with: throw new NotImplemented(); | |
} | |
new ConsumerOfInterface().Consume(partialImpl); // this is valid! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment