Hide virtual method implementation if overloaded method is present in concrete implementation?

"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!

You would basically need to just validate the string in the derived class: public class ConcreteEnum : Abstract { public void DoSomething( Enum e ) { base. DoSomething( "String somehow extracted from enum"); } public override void DoSomething( string s ) { // Validate s, then do something with it } } You can't remove the method entirely, since it is a member of the superclass and hence part of the class interface. For example, if you passed an instance of ConcreteEnum to a method that takes an Abstract object and expected the DoSomething(string) method to work, but it was magically gone, all hell would break loose But you always have the option of overriding the behavior in a subclass to throw exceptions when an invalid value is supplied.

You could even override it to just throw a NotSupportedException EDIT: If the base class DoSomething method is not supposed to be consumed except in subclasses (not saying it is, but you didn't really specify either way), why not just make it protected?

You would basically need to just validate the string in the derived class: public class ConcreteEnum : Abstract { public void DoSomething( Enum e ) { base. DoSomething( "String somehow extracted from enum"); } public override void DoSomething( string s ) { // Validate s, then do something with it } } You can't remove the method entirely, since it is a member of the superclass and hence part of the class interface. For example, if you passed an instance of ConcreteEnum to a method that takes an Abstract object and expected the DoSomething(string) method to work, but it was magically gone, all hell would break loose.

But you always have the option of overriding the behavior in a subclass to throw exceptions when an invalid value is supplied. You could even override it to just throw a NotSupportedException. EDIT: If the base class DoSomething method is not supposed to be consumed except in subclasses (not saying it is, but you didn't really specify either way), why not just make it protected?

Because ideally, it does serve a purpose - not ALL of the derived classes are restricted to a given set of values. Some of them can accept ANY value, and for those the default DoSomething( string s ) implementation. Think of DoSomething( Enum e ) as merely a wrapper around DoSomething( string s ), except that if ( Enum e ) is available, it absolutely MUST be used.

– Clyde Nov 12 '10 at 0:39 With that said, I hadn't considered re-validating in the concrete implementation - that was the primary purpose of using the enum in the first place, to enforce the value list. Re-validating on the other side is certainly possible though. – Clyde Nov 12 '10 at 0:42 It's up to you which approach you take -- validating the string, or throwing an exception -- but either will work.

And doing nothing at all won't have the effect you want. :) – cdhowie Nov 12 '10 at 4:26.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions