S
sougata12
Guest
SHARED can only be sued in a Module level. As per MSDN documentation, Module level means the following:
within a class, structure, module, or interface but not within a procedure or block
If that be the case can anyone explain why am I getting an error (see below code) in the statement Public Shared a As Integer
Module Module1
Public Shared a As Integer 'Not allowed
Public Class Car
Public Shared b As Integer 'Allowed
End Class
Sub Main()
Shared e As Integer 'Not allowed
End Sub
End Module
I believe it is satisfying all the condition of being within a module but not being within a block or procedure. So why the error?
Also, I understand from the above code that SHARED cannot be used within Sub Main() because then it violates the condition of not being within a procedure or block. Is my understanding correct?
Regards,
Sougata Ghosh
Sougata Ghosh
Continue reading...
within a class, structure, module, or interface but not within a procedure or block
If that be the case can anyone explain why am I getting an error (see below code) in the statement Public Shared a As Integer
Module Module1
Public Shared a As Integer 'Not allowed
Public Class Car
Public Shared b As Integer 'Allowed
End Class
Sub Main()
Shared e As Integer 'Not allowed
End Sub
End Module
I believe it is satisfying all the condition of being within a module but not being within a block or procedure. So why the error?
Also, I understand from the above code that SHARED cannot be used within Sub Main() because then it violates the condition of not being within a procedure or block. Is my understanding correct?
Regards,
Sougata Ghosh
Sougata Ghosh
Continue reading...