Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MyBase

Status
Not open for further replies.

VBXL

Programmer
Jul 10, 2001
198
GB
Hi

Please some explain the Keyword "Mybase".
I have read some examples on other websites but i cannot understand it.

Please will someone show me an example when to use mybase.

Cheers

VBXL
 
Mybase means always look in the base class for the property, not the property held in derived class.

An example of this would be an overridded Age property that looked at the today's year minus date of birth year. This is fine for most employers apps but terrible if you're looking for whether they can vote of not. Hence you would refer to Mybase.DOB, not Me.DOB

Craig
 
VBXL -

When your class inherits from another class (and in .NET they *all* inherit from System.Object), you use the MyBase keyword to refer to the class you're inheriting from (the parent).

Typically it's used when you're overriding a method originally provided by the parent class, and you need to call the parent before doing some work yourself. Happens all the time when you write a custom control.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top