hi
what is the difference between overloading and overriding?
and what is the advantage of overriding?
thanks
Overloading allows you to create a function with multiple sets of parameters. This allows for a wide range of data be used. One place I use this is in a data class I created. I will allow for a stored proc name to be passed and parameters, but it also allows for just the SP name if no parms are needed. This way in the user doesnt have to pass Nothing for the parm list each time.
function Overloads GetData(SPName as string, parms as system.collection.arrayList)
function Overloads getData(SpName as string)
Overriding is used when you want to do something instead of what the class normally would do. The easiest way to think of this is if you create a custom control. In that control, you might want to access your DB after the user inputs some data into your control. Instead of needed to add the code to every pages onLoad, you can add it to your custom control by OVERRIDING the onLoad function.
ProtectedOverridesSub onLoad(ByVal eAs EventArgs)
Hope this helps,
Nick
0 comments:
Post a Comment