C#属性内存使用情况? [英] C# property memory usage?

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

问题描述

Imgur:互联网上最棒的图片 [ ^ ]



有了这张图片,我想错了还是这样?



我尝试了什么:



写资产时,哪种方式更正确?

Imgur: The most awesome images on the Internet[^]

With that image, Am I thinking wrong or is that true?

What I have tried:

When writing property, which way is more correct?

推荐答案

下次,只需将代码放在帖子中,而不是放在图片中。



不,你错了8字节。



图片中的顶级代码片段只是一个快捷方式,一个自动实现的属性。在幕后,它与图像中的第二个代码片段完全相同。



在这两种情况下,分配只是一个32位整数,4个字节存储值。
Next time, just put the code in the post, not in an image.

No, you're wrong about the "8 bytes".

The top code snippet in the image is just a shortcut, an "auto-implemented" property. Behind the scenes it's doing exactly the same thing as the second code snippet in the image.

In both cases, the allocation is just a 32-bit integer, 4 bytes to store the value.


这篇关于C#属性内存使用情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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