c#装箱与拆箱

static void Main(string[] args)
        {
            //二者必须存在继承关系
            //装箱(值类型变引用类型)
            //拆箱(引用类型变值类型)

            int n = 10;
            object o = n;//装箱
            int nn = (int)o;//拆箱

            //此处未发生任何装拆箱事件,因为没有继承关系

            string str = "123";
            int a = Convert.ToInt32(str);
        }

 

posted @ 2019-04-18 20:54  _Huang95  阅读(158)  评论(0编辑  收藏  举报