引用类型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

  

posted on 2014-10-17 03:02  王老二  阅读(127)  评论(0编辑  收藏  举报