I still remember the day I discovered private virtuals in C++. That was fun 
stuff, particularly trying to shoehorn that trick into the project I was 
working on just to confuse the hell out of my project lead for the day.

*sigh* Ah, good times.

Ted Neward
Java, .NET, XML Services
Consulting, Teaching, Speaking, Writing
http://www.tedneward.com
 

> -----Original Message-----
> From: Discussion of advanced .NET topics. [mailto:ADVANCED-
> [EMAIL PROTECTED] On Behalf Of Brad Wilson
> Sent: Wednesday, March 12, 2008 1:11 PM
> To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
> Subject: Re: [ADVANCED-DOTNET] virtual explicit interface members
> 
> 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
> 
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.518 / Virus Database: 269.21.7/1327 - Release Date:
> 3/12/2008 1:27 PM
> 

No virus found in this outgoing message.
Checked by AVG. 
Version: 7.5.519 / Virus Database: 269.22.0/1342 - Release Date: 3/25/2008 
10:26 AM
 

===================================
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