Skip to content

Instantly share code, notes, and snippets.

@gsscoder
Created February 14, 2013 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gsscoder/4955513 to your computer and use it in GitHub Desktop.
Save gsscoder/4955513 to your computer and use it in GitHub Desktop.
C# wish list: Partial Implementation of Interfaces
/*
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