引用类型a=b

List<int> list = new List<int>();
        list.Add(1);
        list.Add(2);        
        list.Add(3);
        Cache["Key"] = list;

        var list2 = Cache["Key"] as List<int>;
        List<int> listNew = list2;
        listNew.Add(4);

        if (list2 != null && list2.Count > 0)
        {
            foreach (int i in list2)
            {
                Response.Write(i + "<br/>");
            }
        }
结果1234

  

原文地址:https://www.cnblogs.com/sen068/p/4030108.html