Application.Add、Application.RemoveAt、 Application.Remove、Application.Clear的用法

在讲述Application.add的用法前,我们先来看下面这段代码:

 

 

 Application.Add("App1", "Value1");
            Application.Add("App2", "Value2");
            Application.Add("App3", "Value3");
            for (int i = 0; i < Application.Count; i++)
            {
                Response.Write("变量名: " + Application.GetKey(i));
                Response.Write(",值: " + Application[i] + "<p>");
            }

 

======================此段代码输出结果为================

 

变量名: App1,值: Value1

变量名: App2,值: Value2

变量名: App3,值: Value3

 

 

我们再来看下面这段代码:

 Application.Add("App1", "Value1");
            Application.Add("App2", "Value2");
            Application.Add("App3", "Value3");
            for (int i = 0; i < Application.Count; i++)
            {
                Response.Write("变量名: " + Application.GetKey(i));
                Response.Write(",值: " + Application[i] + "<p>");
            }
          
            Application.RemoveAt(1);-------------------------------------------------------------删除了 ("App2", "Value2");

            Application.Remove("App3");----------------------------------------------------删除了 ("App3", "Value3");

            Response.Write("删除两个变量后" + "<br>");
            Response.Write("<Script>alert("+Application.Count+")</script>"); ----------弹出1
            for (int i = 0; i < Application.Count; i++)
            {
                Response.Write("变量名:" + Application.GetKey(i) );
                Response.Write(",值:" + Application[i] + "<p>");
            }
            Application.Clear();

         Response.Write("<Script>alert("+Application.Count+")</script>"); ----------弹出0

   

======================此段代码输出结果为================

变量名: App1,值: Value1

变量名: App2,值: Value2

变量名: App3,值: Value3

删除两个变量后
变量名:App1,值:Value1


   }


到这里,想必大家就知道application里面方法的用法了吧。。现在总结一下:

Application.Add:添加对象

Application.RemoveAt:移除索引对象

Application.Remove:移除名称对象

Application.Clear:清空application

 

阅读更多
文章标签: application
上一篇ASP.NET 重要对象 HttpApplication
下一篇list{1,2,3,4,5,6,7}转换成 list / string
想对作者说点什么? 我来说一句

CListCtrl的用法

2011年02月28日 372KB 下载

varbinary用法

2011年05月07日 301B 下载

没有更多推荐了,返回首页

关闭
关闭