静态变量的生命周期 [英] Lifecycle of Static Variables

查看:63
本文介绍了静态变量的生命周期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何方法可以设置静态变量的生命周期-即:在重置之前它保持活动状态有多长时间?我希望可能会有一个可以应用的属性.

Is there any way to set the life cycle of a static variable - ie: how long it's kept alive before being reset? I was hoping there may be an attribute which can be applied.

推荐答案

静态成员与类型本身相关联,而不与该类型的实例相关联.因此,它们的生命周期仅限于其创建的时间和顺序,并且不会因类型的实例而被重置".

Static members are associated with the type itself, not with an instance of the type. Therefore their lifecycle is limited to the timing and ordering of their creation, and they don't get "reset" by instances of the type.

这篇关于静态变量的生命周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆