Reputation: 13350
Let's say that I have two .Net applications running on a single machine. Both applications access a static property in a class. Considering the following scenario in sequential order:
FooClass.MyStaticString = "A";
Application B
FooClass.MyStaticString = "B";
Application A
Console.WriteLine(FooClass.MyStaticString);
Would the result be "A" or "B"? I'm just curious how static .Net statics really are.
Upvotes: 1
Views: 195
Reputation: 11495
They are limited to the specific AppDomain. Each application at a minimum has its own unique AppDomain, so the static property/field is not shared across the applications. It would be "A" as a result. Similarly, if you fired up multiple AppDomains within one process, the static property/field would not be shared between those either.
Upvotes: 4