Does shadowing through scope work when the programming elements are of different types?

  • Thread starter Thread starter sougata12
  • Start date Start date
S

sougata12

Guest
Hi,

MY question is:

If two programming elements have the same name but are of different types and have different scopes, then can one of them shadow the other through scope? For example, in the below case the name TEMP has been assigned to both an integer variable and a sub-routine with different scopes but it is not working. So is there a way to make it work (apart from qualifying it with Module1)...i.e. to make the TEMP integer variable shadow the TEMP() subroutine? OR does shadowing through scope only work when the two programming elements are of the same type?


Module Module1

Public t As Integer = 42
Sub temp()
Console.WriteLine("TEMP from sub printTemp: {0}", t)
End Sub

Sub Main()
Dim temp As Integer = 5
Console.WriteLine("TEMP from sub Main(): {0}", temp)
temp() 'error comes here. but Module1.temp() works fine
Console.ReadLine()
End Sub
End Module

Error is as follows:

1510768.png

PLease help








Sougata Ghosh

Continue reading...
 
Back
Top