Is there a way to reinitialize a shared variable?

P

Peter

I have the following class:

public class Test

private shared mObject as Object = New myclass.object
....

Normally, a new instance of that class will share the existing value of
mObject. However, for some special cases, I need it to reinitialize mObject
as if mObject is not declared as shared.
 
M

Michel Posseth [MCP]

Hello Peter

my first guess would be create a shared method were you reinitialize the
variabel when needed

public class Test

private shared mObject as Object = New myclass.object

Public shared sub ReInitObject

mObject=New myclass.object

end sub

......

............


Bether in my opinion would be to avoid static instances at all , as it is
considered as bether coding practice
( or you must have a verry good reasson to use shared , static fields and or
methods


HTH

Michel
 
C

Cor Ligthert[MVP]

public class Test
private shared mObject as Object = New myclass.object
...
Can you explain a little bit more with this code.

myclass denotes the objects inside the class when it is instanced.
To instance an object you need a type (a class but not itself)

On the other hand why are you doing it so difficult to avoid OOP.
Just use only modules if you are not able to use OOP.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top