c# - Can I reset a static/shared class? -


I have a shared class ( still in C # ), Which mostly data data, which can read any class and can sometimes write, there are also static properties which hold some internal states.

Now I want to return this class to its initial phase. With all default variables and so on assume that the user wants to reset the current state and start the application without restarting it.

In a singleton model I will just renew it with something like this:

  public sub-reset (_Instance = new MyClass ()) end sub  

However this is shared class How can I complete this? Or should I switch the singleton back ?

There is no way to do this, it is the same way as the singleton model that you just said. The reason for this is that there is no backing data store to "reset" what you can do though, it is simulating this by using a clear method to initialize all our data. Public module MyClass public sub reset () field 1 = 42 field 2 = "foo" and sub-public share field 1 integer public sharing field 2

 

Versions with a class vs. a module

  Public Classes Myself Shared Sub New ( ) Reset and sub private sub new () 'class and sub folk all reset () immediately stop field 1 = 42 field 2 = "afu" end By public stock Field 1 Intigr public shared Field 2 As String End Class  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -