Overriding a class

When overriding a class such as:

       public override void OnCreate()

Open in new window

Is it best to call the base method BEFORE or AFTER your code? And reasons why please.

Thanks :)
Who is Participating?
käµfm³d 👽Connect With a Mentor Commented:
Well typically the base implementation is what actually raises the event. The decision you have to make is whether not you want the client to see the event before your code runs or after your code runs, or to never see it all. ( more or less what Andy said. )
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
>>Is it best to call the base method BEFORE or AFTER your code?

Depends on what you do.  Sometimes before, sometimes after, sometimes makes no difference.
John ClaesConnect With a Mentor Senior .Net Consultant & Technical AnalistCommented:
Example :

For Constructor you mostly set it first : you are then sure that it's constructed
For destruction set is as last : you want it to be destructed after you've destructed all the addon's

For the other methods, it's all about what the others said, just trying to clear it out a little more with the 2 examples
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

AndyAinscowFreelance programmer / ConsultantCommented:

Very good point, re c'tor and d'tor
zattzAuthor Commented:
I guess I'll have to try it out and see what works best. I'm developing for Android, so I'm in the dark mostly :) Thanks for the help
käµfm³d 👽Commented:
Not to discredit my fellow experts, but you might try posting your question in the Android TA. (Myself, I have only dabbled in Android development.)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.