讨论,GenerateMember = False [英] Discussion, GenerateMember = False

查看:143
本文介绍了讨论,GenerateMember = False的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人通过将GenerateMember变量设置为false来注意到任何性能问题或内存改进.

据我所知,它只是在InitializeComponent()存根内部局部声明了变量,因此我猜想该变量将能够由GC收集并在使用后清除.这样会改善性能或内存分配吗?

例如,如果菜单条中的菜单项列表很长,而您只需要处理它们的click事件,并且永远不要在运行时访问它们的任何属性,则可以很好地利用此功能.但是,牺牲会奏效吗?

您对此有何想法?

I was wondering if someone has noted any performance issue or memory improvement by setting the GenerateMember variable to false.

As far as i have seen, what it does is just declare the variable locally inside InitializeComponent() stub, so i guess that this variable would be able to be collected by GC and cleaned after used. would this improve performance or memory allocation?

For instance, a good use of this would be if you have a long list of menu items in a menu strip, and you just need to handle their click event and never access any of their properties in runtime. But, will it work the sacrifice ?

What are your thought regarding this?

推荐答案

我总是想记住将其设置为False ,以用于我无法在代码中访问的控件(通常是他们中的大多数).我认为这不会以任何明显的方式影响性能.

与WPF相比,借助MVVM,很少有人需要命名控件(样式,模板等除外).

因此,如果您希望将它们设置为False,请继续进行,不会有任何影响,并且您会在自动生成的代码中摆脱一些多余的成员变量.
I always mean to remember to set it to False for controls I don''t access in code (which is usually the majority of them). I don''t think it would affect performance in any noticeable way.

Comparing to WPF, with MVVM it''s rare that anyone will ever need to name their controls (except for styles, templates etc.)

So if you prefer to set them to False, go ahead, it won''t affect anything, and you will get rid of some superfluous member variables in the auto generated code.


我认为,如果您的计算机速度太慢以至于会有所作为,则需要在算盘上进行交易.
I think if your computer is so slow that this would make a difference, you need to trade it in on an abacus.


这篇关于讨论,GenerateMember = False的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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