c# - Fully qualified interface name in inheritance -


this question has answer here:

there 2 interfaces defined as:

interface calc1 {     int add(int a, int b); } interface calc2 {     int add(int x, int y); } 

a class implements both these interfaces as:

class calculation : calc1, calc2 {     public int result1;     public virtual int add(int a, int b)     {         return result1 = + b;     }         } 

everything works fine. when change class definition as:

class calculation : calc1, calc2 {     public int result1;     public int result2;     public virtual int calc1.add(int a, int b)     {         return result1 = + b;     }      public int calc2.add(int x, int y)     {         return result2 = x - y;     } } 

i see errors:

the modifier 'virtual' not valid item 

and

the modifier 'public' not valid item 

what wrong in latter class code?

explicit interface implementations can't have access modifier, since visible when using interface type. there no point in making public.

also, can't derived explicit interface implementation, virtual useless too. compiler knows , breaks on it.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -