winform简单缓存类实例

内容摘要
本文实例讲述了winform简单缓存类。分享给大家供大家参考。具体如下:


public partial class Form3 : Form
{
//缓存类
System.Web.Caching.Cache cache;
public Form
文章正文

本文实例讲述了winform简单缓存类。分享给大家供大家参考。具体如下:

public partial class Form3 : Form
{
  //缓存类
  System.Web.Caching.Cache cache;
  public Form3()
  {
   InitializeComponent();
   string SQL = "select top 1000 * from infomation";
   DataTable datatable = DBHelper.GetDataTable(SQL, ConnType.Menu);
   dataGridView1.DataSource = datatable;
   cache = System.Web.HttpRuntime.Cache;
   cache.Insert("infomation", datatable);
  }
  private void button1_Click(object sender, EventArgs e)
  {
   if (cache != null) {
    DataTable table = cache["infomation"] as DataTable;
    dataGridView2.DataSource = table;
   }   
  }
}

希望本文所述对大家的C#程序设计有所帮助。


代码注释

作者:喵哥笔记

IDC笔记

学的不仅是技术,更是梦想!