nov*_*ato 1 .net c# garbage-collection
Below is code snippet in which I am getting generation of variable int j before and after calling garbage collector.
int j = 30;
WriteLine(GC.GetGeneration(j) );
GC.Collect();
WriteLine(GC.GetGeneration(j));
Run Code Online (Sandbox Code Playgroud)
The output should be
0
1
Run Code Online (Sandbox Code Playgroud)
as int j is surviving garbage collection But I am getting
0
0
Run Code Online (Sandbox Code Playgroud)
我不明白为什么会发生这种情况,因为int它也是 C# 中的一个对象。PS:我试过在调试和发布模式下运行项目。
| 归档时间: |
|
| 查看次数: |
69 次 |
| 最近记录: |