小编zbl*_*ago的帖子

跨几个变量的引用类型分配

我要问的问题让我感到困惑,只是因为我正在深入研究一些 C# 细节。考虑以下代码:

    public class Node 
    {
         public int Data {get;set;}
    }
  
   var a = new Node() { Data = 1 }; // address in memory 0x600000
   var b = new Node() { Data = 2 }; // address in memory 0x700000
   var c = new Node() { Data = 3 }; // address in memory 0x800000

   a = b;  // variable a holds a reference to the memory location of b -> 0x700000
   b = c;  // variable b …
Run Code Online (Sandbox Code Playgroud)

.net c# reference

2
推荐指数
1
解决办法
109
查看次数

标签 统计

.net ×1

c# ×1

reference ×1