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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -