I need to build up a List<object>
and cache the list and be able to append to it. I also need to be able to blow it away easily and recreate it. What is a simple way to accomplish this?
The SIMPLEC (Semi-Implicit Method for Pressure Linked Equations-Consistent) algorithm; a modified form of SIMPLE algorithm; is a commonly used numerical procedure in Computational Fluid Dynamics to solve the very famous Navier–Stokes equations. This algorithm was developed by Van Doormal and Raithby in 1984.
C++ was designed to be easier to use and to allow programmers to make efficient use of computer resources. C++ also has some similarities with C, but there are some important differences. C++ is a good choice for experienced programmers who want to learn a new programming language.
While C is one of the more difficult languages to learn, it's still an excellent first language pick up because almost all programming languages are implemented in it. This means that once you learn C, it'll be simple to learn more languages like C++ and C#.
Something like this perhaps?
using System;
using System.Collections.Generic;
using System.Web;
public class MyListCache
{
private List<object> _MyList = null;
public List<object> MyList {
get {
if (_MyList == null) {
_MyList = (HttpContext.Current.Cache["MyList"] as List<object>);
if (_MyList == null) {
_MyList = new List<object>();
HttpContext.Current.Cache.Insert("MyList", _MyList);
}
}
return _MyList;
}
set {
HttpContext.Current.Cache.Insert("MyList", _MyList);
}
}
public void ClearList() {
HttpContext.Current.Cache.Remove("MyList");
}
}
As for how to use.....
// Get an instance
var listCache = new MyListCache();
// Add something
listCache.MyList.Add(someObject);
// Enumerate
foreach(var o in listCache.MyList) {
Console.WriteLine(o.ToString());
}
// Blow it away
listCache.ClearList();
This Tutorial is what I found to be helpful
Here is a sample
List<object> list = new List<Object>();
Cache["ObjectList"] = list; // add
list = ( List<object>) Cache["ObjectList"]; // retrieve
Cache.Remove("ObjectList"); // remove
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With