.Net Static Class Property Scope as it Pertains to the Runtime
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:
Application A
FooClass.MyStaticString = "A";
Application B
FooClass.MyStaticString = "B";
Application A
开发者_JS百科Console.WriteLine(FooClass.MyStaticString);
Would the result be "A" or "B"? I'm just curious how static .Net statics really are.
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.
精彩评论