punjabtechnicaluniversity.blogspot.in
Public Class ClsParent
Public x As Integer
End Class
Public Class ClsShadowedParent
Inherits ClsParent
Public Shadows x As String
End Class
When two elements in a program have same name , one of them can hide and shadow the other one.So in such cases the element which shadowed the main element is referenced. Below is a sample code , there are two classes “ClsParent” and “ClsShadowedParent”.In “ClsParent” there is a variable “x” which is a integer.”ClsShadowedParent” overrides “ClsParent” and shadows the “x” variable to a string.
Note:- In Sample CD “WindowsShadowing” is folder which has the sample code.If you run the program you can have two output’s one which shows a integer and other which shows a string.
Public Class ClsParent
Public x As Integer
End Class
Public Class ClsShadowedParent
Inherits ClsParent
Public Shadows x As String
End Class
Shadowing in Action
0 comments:
Post a Comment
North India Campus