c#中类在运行中的生存周期

 class student
    {
        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }

  student sd = new student();

编译器执行代码:

一、在栈中开辟student类型的内存空间放置变量sd;

二、在堆中创建该变量的对象;

三、调用该对象的构造函数,返回该对象在堆中的地址

c#中类在运行中的生存周期

c#中类在运行中的生存周期

上一篇:Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并(转)


下一篇:[Cache] C#操作缓存--CacheHelper缓存帮助类 [复制链接]