Search Results

Search found 1 results on 1 pages for 'fnatte'.

Page 1/1 | 1 

  • Make sure base method gets called in C#

    - by Fnatte
    Can I somehow force a derived class to always call the overridden methods base? public class BaseClass { public virtual void Update() { if(condition) { throw new Exception("..."); // Prevent derived method to be called } } } And then in a derived class : public override void Update() { base.Update(); // Forced call // Do any work } I've searched and found a suggestion to use a non-virtual Update() but also a protected virtual UpdateEx(). It just doesn't feel very neat, isn't there any better way? I hope you get the question and I am sorry for any bad English.

    Read the article

1