很简单的一个问题:

 

IDictionary<string ,string > tempDic= new Dictionary<string ,string >();

IDictionary <string ,string > tempDic2= new Dictionary<string ,string >();

tempDic2=tempDic;

 

tempDic= null;

tempDic.Clear() 后,tempDic2的结果的区别.

 

最后结果是:

对于tempDic=null,tempDic2里面还是保存了tempDic的内容.

对于tempDic.Clear(),tempDic2里面没有任何值;

 

当然,最终原因,还是引用类型的问题.

 

 

本想用个图来说明,不太好画,也就省略了...

 

如果以内存地址来说,则非常的容易明白....

 

 

 

 

 

相关文章:

  • 2021-04-08
  • 2021-11-13
  • 2021-09-13
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2021-05-26
  • 2021-08-11
相关资源
相似解决方案