c#装箱与拆箱

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

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

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

            string str = "123";
            int a = Convert.ToInt32(str);
        }
原文地址:https://www.cnblogs.com/huangxuQaQ/p/10732285.html