|
-
May 8th, 2009, 12:18 PM
#1
Thread Starter
Not NoteMe
[RESOLVED] Classes using an interfaces extension method
Hi all,
I have an interface (IMessageDispatcher) which has an extension method (DispatchMessages) containing code that would be identical in all classes that implement it.
I don't want to code the identical method in every class that implements the interface.
If i leave out the method in the class i get a compiler error, class does not implement interface, but i don't want to implement it as there is an extension method already there.
I've tried casting to the interface to call the extension method, but it still calls my class' wrapper method, so i get a stack overflow:
Code:
public void DispatchMessages()
{
(this as IMessageDispatcher).DispatchMessages();
}
How can i avoid writing identical code in all classes that implement this interface?
Cheers!!
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|