日期:2014-05-17 浏览次数:20685 次
public static class Session { private static Hashtable table = new Hashtable(); public object this[object key] { get { return table[key]; } set { table[key] = value; } } }
------解决方案--------------------
这点问题还要发代码哦。。。。 只能说你的思路太差了。。
public class AppDataCenter { protected static SortedList<string, object> _session=new SortedList<string , object> (); public static SortedList<string, object> Session { Get { return _session; } } public static object GetValue(string name) { object reo = null; lock(_session) { if( _session.ContainsKey(name)) { reo = _session[name]; } } return reo; } public static void SetValue(string name, object OBJ ) { lock(_session) { if( _session.ContainsKey(name)) { _session[name]=OBJ; } else { _session.Add(name, OBJ); } } } } 调用 myclass M = new myclass(); AppDataCenter.SetValue("abc", M) ; myclass MC = (myclass) AppDataCenter.GetValue("abc"); if(MC!=null) { ..... }