logo
  • 教程列表
  • SO官方文档
  • 值类型与引用类型
    • 使用 ref 关键字通过引用传递
    • 改变别处的值
    • 通过引用传递
    • 分配
    • 与方法参数 ref 和 out 的区别
    • ref vs out 参数
  1. StackOverflow 文档
  2. C# Language 教程
  3. 值类型与引用类型
  4. 分配

分配

Created: November-22, 2018

var a = new List<int>();
var b = a;
a.Add(5);
Console.WriteLine(a.Count); // prints 1 
Console.WriteLine(b.Count); // prints 1 as well

分配给 List<int> 的变量不会创建 List<int> 的副本。相反,它将引用复制到 List<int>。我们调用以这种方式表示引用类型的类型。

  • 与方法参数 ref 和 out 的区别
  • 通过引用传递

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明