The final example will bind you to a solid instance of either an interface or an abstract class, which, I believe, is not your goal. The bad news is that you are not a dynamically typed language, so you are stuck either with a link to solid "Example" objects, as previously set or cast / unwanted, i.e.:
AbstractExample example = new Example(); ((IExampleInterface)example).DoSomeMethodDefinedInInterface();
Your other alternatives should have both AbstractExample and IExampleInterface implement a common interface so you can: i.e.
abstract class AbstractExample : ICommonInterface interface IExampleInterface : ICommonInterface class Example : AbstractExample, IExampleInterface
Now you can work with ICommonInterface and have the functionality of both an abstract class and the implementation of your IExample interface.
If none of these answers is acceptable, you might want to take a look at some of the DLR languages ββthat run under the .NET platform, i.e. IronPython.
source share