If I create a static property MyLanguage and one request sets its value to 1, while at the same time another thread sets it to 2 - what will be the final value of MyLanguage?
Does the single MyLanguge property gets shared across ASP.NET sessions?
A static property/field is shared across the app domain. So all your sessions should see the same value.
The only exception is when you use the ThreadStatic attribute on a static field, in which case each thread will see its own value. e.g.
[ThreadStatic]
static int counter = 0; // each thread sees a different static counter.
It would be 2. Static fields, properties are shared between objects.So Latest set values will be updates for all the instances.
From MSDN
Use the static modifier to declare a static member, which belongs to the type itself rather than to a specific object. The static modifier can be used with classes, fields, methods, properties, operators, events, and constructors, but it cannot be used with indexers, destructors, or types other than classes. For more information
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With