开发者

.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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜