You're missing a word in your description: "private explicit
implementation". The implementation method IFoo.Bar() is private. Make a
private method virtual doesn't make sense.

Because it's an implementation of an interface, any derived class which
wishes to re-implement that interface merely needs to _also_ do a private
explicit implementation as well. The virtual/override keywords are not
required.

On Wed, Mar 12, 2008 at 11:38 AM, Simon Robinson <[EMAIL PROTECTED]>
wrote:

> This code won't compile:
>
> interface ITest
> {
>  bool Foo();
> }
>
> public class Base : ITest
> {
>  virtual bool ITest.Foo() { return true; }
> }
>
> The compiler objects to making ITest.Foo() virtual - it seems that for
> some reason C# won't allow an interface member to be virtual or abstract
> if it's been implemented explicitly (although if I don't implement it
> explicitly, the compiler is quite happy with the virtual/abstract
> modifier). Anyone know what the rationale for such a restriction would be?
> Offhand I can't see why doing that should be problematic.
>
> ===================================
> This list is hosted by DevelopMentor(R)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>



--
http://bradwilson.typepad.com/
http://www.flickr.com/photos/dotnetguy/
http://www.last.fm/user/dotnetguy/

===================================
This list is hosted by DevelopMentor�  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to