用.net静态变量取代Application,速度更快
来源:互联网 发布:遗传算法的数学基础 编辑:程序博客网 时间:2024/05/19 10:09
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
在传统的ASP中,我们要用application对象去存储应用于整个application的变量。这当然会带来内存消耗的代价。在.net中,我们可以用static变量来改善它,采用static 变量在大多数时候存储的速度会比application对象快。做法:
创建一个webApplication,假设名称为webApplication1,在Global.aspx中的Global类中增加一个静态的成员sGreeting.
public class Global : System.Web.HttpApplication
{
public static string sGreeting = "China is great!";
……
}
在WebForm1中增加一个label,名称为label1.
在page_load()中为label1的text属性赋值。
private void Page_Load(object sender, System.EventArgs e)
{
Label1.Text = WebApplication1.Global.sGreeting;
}
运行程序后将会看到China is great!
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 用.net静态变量取代Application,速度更快。
- 用.net静态变量取代Application,速度更快
- [转贴]用.net静态变量取代Application,速度更快
- 用.net静态变量取代Application,速度更快
- MyEclipse启动速度更快
- Apache 网站速度更快
- 在.NET中使用静态变量来代替Application变量
- 让单片机运行速度更快一些
- 让QQ启动速度更快
- 让QQ启动速度更快
- 其实FireFox的速度可以更快
- 让单片机运行速度更快一些
- 键盘操作电脑,速度更快!
- 如何让J2EE开发速度更快
- 如果使网页访问速度更快
- 串行, 并行,速度哪个更快。
- ubuntu 各版本更新源,速度快
- jquery怎么写速度才能更快
- 数据库连接字在Web.config里的用法
- ASP.NET图象处理详解(2)
- 使用JScript.NET创建asp.net页面
- ASP.NET图象处理详解(1)
- 改写即时消息的发送,包含同时给多人发送信息!
- 用.net静态变量取代Application,速度更快
- ASP.NET编程中的十大技巧
- TreeView使用笔记
- 我的aspx为什么无法显示中文
- 中国集成电路崛起的根源
- asp.NET特写
- .net中即时消息发送的实现……
- ASP.NETViewState初探(2)
- 在ASP.NET中值得注意的两个地方