c# - Static Members of an Instance Class -


Static members of an instance class remain only for example, or static members will survive throughout the lifetime of the application?

For example, I have a hashable as a fixed asset, if I had added it to an "instant" item, would they be available from other "instances"?

They live throughout the lifetime of AppDomain . (For Windows applications, this is usually the life of the process, however, what you really are doing. AppDomains is periodically recycled in ASP.NET .)

Do not think about sharing between instances of static variables - think of them as belonging to type instead of a particular example. For example:

  class test {static x x}  

For example:

= 0; Static zero main () {x = 10; Console.WriteLine (x); }}

There are no examples around "share" test.x - but that's okay because it is with test Example 's Test .

You can argue that this is a very subtle difference, but it has proved useful to me.


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%? -