Silverlight模拟ASP.NET Session相应操作(二)

上一篇写道了SessionManager类,以下是对这个类的使用:

1.为 Session 赋值:

// 通过Session赋值
// 创建对象
MapLayerInfo layer = new MapLayerInfo();
layer.LayerName = "图层一";
layer.MapLayer = new MapLayer();
// 将该对象赋值给Session
Global.Session["layer"] = layer;
// 创建数组对象
string[] Array = { "张三", "李四", "王五" };
Global.Session["Array"] = Array;

2.从 Session 取值:

// 通过Session取值
// 获取MapLayerInfo对象
MapLayerInfo layer = Global.Session["layer"] as MapLayerInfo;
// 获取Array String 字符集合
string[] Array = Global.Session["Array"] as string[];

猜你喜欢

转载自alovejun.iteye.com/blog/1112805