我有一本字典,我把它放在会话中,在每个按钮上单击我都需要执行一些操作。
itemColl = new Dictionary<int, int>();
我想搜索我在会话变量中维护的键,如果键存在,那么我想将相应键的值增加 1,我该如何实现。
我正在尝试如下:
if (Session["CurrCatId"] != null)
{
CurrCatId = (int)(Session["CurrCatId"]);
// this is the first time, next time i will fetch from session
// and want to search the currcatid and increase the value from
// corresponding key by 1.
itemColl = new Dictionary<int, int>();
itemColl.Add(CurrCatId, 1);
Session["itemColl"] = itemColl;
}