我要投稿

不要节约使用变量

时间:2010-08-13 09:34 作者:cccbbs 阅读:1150

扫描二维码关注公众号,可以查询淘宝、京东商品优惠券

            
                                  

[/td]
            
Now, you might be wondering, what does he mean, Don't skimp on the variables? Well, often times it is more

efficient to use variables to store results from ADO queries or from objects, and then reference the

variable as opposed to continuously referencing the object.



For example, you could do this:





If Request.QueryString("Name") = "Frank" Then

???...

End If



If Request.QueryString("Name") = "Steve" Then

???...

End If



Response.Write("Your name is " & Request.QueryString("Name"))

Each time you use the Request object, ASP has to go read the QueryString variable name. You can reduce

this to having to just read this once by doing the following:





Dim strName

strName = Request.QueryString("Name")



If strName = "Frank" Then

???...

End If



If strName = "Steve" Then

???...

End If



Response.Write("Your name is " & strName)

Plus, I personally think the above scenario is easier to read. It's easier, I think, to mentally associate

strName to be the user's name as opposed to associating Request.QueryString("Name") as the user's name.

Just my two cents, though!?

最新评论

我要投稿 我要评论
插入url链接 添加表情
限 100000 字节
响应相关主管单位规定,关闭回帖发帖功能
[VB毕业设计] [ASP毕业设计] [JAVA毕业设计] [JSP毕业设计] [PHP毕业设计] [asp.net毕业设计] [.net毕业设计] [网络毕业设计] [Delphi毕业设计] [VC毕业设计] [VF毕业设计] [机械毕业设计] [工艺毕业设计] [模具毕业设计] [其他毕业设计]
站长联系 cccbbsnet#163.com 本站系公益性质网站,站内广告维系本站运作。欢迎赞助本站。
大学生计算机相关方向|软件编程|网络工程|web开发|数据库技术|学习资料等
本社区仅供学习计算机相关技术所使用,访客发言不得违反国家法律法规
Time now is:10-16 14:33, Gzip enabled 蜀ICP备07004838号Powered by cccbbs.net v7.5 SP3 Code © 2003-06 cccbbs
计算机毕业设计