class Program
    {
        static void Main(string[] args)
        {
            List<int> lst = new List<int>();
            lst.Add(1);
            lst.Add(2);
            Console.WriteLine("未调用之前");
            Console.WriteLine(lst.Count+string.Join(",",lst));
            ChangeList(lst);
            Console.WriteLine("调用之后");
            Console.WriteLine(lst.Count + string.Join(",", lst));
            Console.ReadLine();
        }

        private static void ChangeList(List<int> lst)
        {
            lst.Clear();
            lst.Add(1000);
            lst.Add(2000);
        }    

输出结果如下:

List<int>是值类型还是引用类型

可见,List<int>是引用类型,可能这个问题大家都知道了,我只是记录自己以后查看而已。

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-01-22
  • 2022-02-07
  • 2021-07-08
  • 2022-12-23
  • 2021-10-04
猜你喜欢
  • 2022-02-15
  • 2021-06-15
  • 2022-12-23
  • 2022-02-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案