循环速度快于直接访问 [英] Is Looping faster then direct access

查看:86
本文介绍了循环速度快于直接访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 这是一个普遍的问题:Q循环遍历控件的速度更快,然后直接在WEB中访问它(如果是),那么如何(如果否)那么一个人如何解释这个问题?
在此先感谢

Hi This is a general Q is looping through controles faster then directly accessing it in WEB if yes then how if no then how can some one plz Explain me this
Thanks in advance

推荐答案

否,循环到列表永远比直接访问数据快.这是因为它将始终执行额外的步骤和检查.
No, looping to lists is never faster than accessing data directly. This is because it will always perform extra steps and checks.


直接访问总是比循环快,因为JV99999指出了原因.
但是在某些情况下,您必须根据某些条件添加/显示随机控件,然后通过循环访问它是设置或检索其值的更好方法.您不必仅通过循环访问每个阶段,可以将TAG添加到每个控件并根据其索引访问特定控件.

结论:对于稳定的控件,直接访问是首选,并且为了动态添加#特定控件(如文本框,复选框等),yuo可以通过循环访问它,但始终不需要循环,也不是首选的方式.

现在,这取决于您的要求以及您要做什么.

希望对您有所帮助!
Direct access is always faster than looping as JV99999 pointed out the reason.

But in certain circumstances where you got to add/show random controls based on some criteria, then accessing it thru loops is better way to set or retrieve its value or so. Not necessary for each stage you got to access it via loop only, you can add TAG to each control and access particular control based on its index.

Conclusion : For stable controls, direct access is preferred and for dynamically adding a # of specific controls (Like textboxes, checkboxes, etc) yuo may access it via loops but always loops are not required and nor the preferred way.

Now it depends on your requirements and what do you want to do.

Hope this helps !


这篇关于循环速度快于直接访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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