C#做常量字段使用较少的内存? [英] C# do const fields use less memory?

查看:172
本文介绍了C#做常量字段使用较少的内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

做常量字段使用比普通变量内存少了?

Do const fields use less memory than regular variables?

推荐答案

字段常量内存消耗取决于它的用法。常量字段的值被嵌入到编译期间IL代码。如果没有一处提到一个const场没有消耗的内存。当有到常量领域的许多引用,那么内存使用量可能取决于代码部分目前居住在内存中繁殖。

Const fields memory consumption depends on its usage. The values of const fields are embedded into the IL code during compilation. Without a single reference to a const field there is no memory consumed. When there are many references to the const field, then memory usage may multiply depending on the code portion currently residing in memory.

这篇关于C#做常量字段使用较少的内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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