码迷,mamicode.com
首页 > 其他好文 > 详细

引用类型a=b

时间:2014-10-17 03:58:23      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   for   sp   div   on   log   

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

  

引用类型a=b

标签:style   blog   color   ar   for   sp   div   on   log   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!