c# - How to implement an interface explicitly with a virtual method? -


i can't this

interface interfacea {     void methoda(); }  class classa : interfacea {     virtual void interfacea.methoda()     // error: modifier 'virtual' not valid item     {     } } 

where following works

class classa : interfacea {     public virtual void methoda()     {     } } 

why? how circumvent this?

i think because when member explicitly implemented, cannot accessed through class instance, through instance of interface.

so making 'virtual' not make sense in case, since virtual means intend override in inherited class. implementing interface explicitly and making virtual contradictory. may why compiler disallows this.

to work around think csharptest.net's or philip's answer sounds trick


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -