Shadowing

The main purpose of shadowing is to protect the definition of your class members.

The base class might undetgo a change that creates an element with the same name as one you have already defined.

If this happens,the shadows modifier forces references through your class to be resolved to the member you defined,

instead of to the new base class element.

 

Shadowing example:

 

public class firstclass

public sub display()

Msgbox("This is firstclass")

End sub

End class

public class secondclass

Inherits firstclass

public class secondclass

Inherits firstclass

private shadows sub display()

msgbox("This is secondclass")

end sub

end class

private shadows sub display()

Msgbox("This is secondclass")

End sub

End class

public class thirdclass

Inherits secondclass

private shadows sub display()

Msgbox("This is thirdclass")

End sub

End class

Module Moduleshadows

sub main()

Dim first As New fristclass

Dim second As New secondclass

Dim third As New thirdclass

''''The following statment displays "This is firstclass".

first.display()

''''The following statment displays "This is firstclass".

second.display()

''''The following statment displays "This is thirdclass".

third.display()

End sub

End Module


Average Rating (0)
by Rinkal   chaudhari  in VB.Net  on 3/24/2015 1:49:34 AM  


Post Your Comment
*