Thursday, July 30, 2009

Data Caching in ASP.Net using C#.Net?

How can i make a class say person with variables like name,age,country etc.and save it in an arraylist..and then save that arraylist in Cache..how can i do all this without making use of database

Data Caching in ASP.Net using C#.Net?
Cache("name") = "mehak"





Response.Write(Cache("name"))





You can declare other Cache Keys to store the data.


See the above example it stores the value in Cache("name") and Response.Write will display the value on page.





Similarly ArrayList can also be stored:


Example:


ArrayList arr1 = new ArrayList();


arr1.Add("mehak");





Cache["myList"] = arr1;





ArrayList arr2 = new ArrayList();


arr2 =(ArrayList)Cache["myList"];


Response.Write(arr2[0]);
Reply:I don't know C#, but I think any variable will go into the Cache, atleast it will go into the ram (that is what I think it should be)


No comments:

Post a Comment