winform简单缓存类实例
本文实例讲述了winform简单缓存类。分享给大家供大家参考。具体如下:
publicpartialclassForm3:Form
{
//缓存类
System.Web.Caching.Cachecache;
publicForm3()
{
InitializeComponent();
stringSQL="selecttop1000*frominfomation";
DataTabledatatable=DBHelper.GetDataTable(SQL,ConnType.Menu);
dataGridView1.DataSource=datatable;
cache=System.Web.HttpRuntime.Cache;
cache.Insert("infomation",datatable);
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
if(cache!=null){
DataTabletable=cache["infomation"]asDataTable;
dataGridView2.DataSource=table;
}
}
}
希望本文所述对大家的C#程序设计有所帮助。