静态成员会收到垃圾吗?

静态成员变量曾经获得垃圾回收吗?


例如,让我们使用以下类。


public class HasStatic {

    private static List<string> shared = new List<string>();


}

并假设它是这样使用的:


//Startup

{

HasStatic a = new HasStatic();

HasStatic b = new HasStatic();

HasStatic c = new HasStatic();

HasStatic d = new HasStatic();

//Something

}

//Other code

//Things deep GC somewhere in here

HasStatic e = new HasStatic();

当a,b,c,和d被垃圾回收不静态成员shared得到收集呢?可能e会得到一个新的实例shared?


哈士奇WWW
浏览 292回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP