Questions
I have this really weird problem and I'm sure I'm missing something obvious here. I have these two lines:.
HttpContext.Current.Session[listModelType + "ListModel"] = listModel; listModel.ProductRows = new Collection<ProductRow>(listModel.ProductRows.Where(r => r.ParentRowId == 0).ToList()); |
After the second line is executed my session object is updated as well (according to "Watch" in Visual Studio)
What am I missing here?
I have tried
int i = 0; HttpContext.Current.Session["i"] = i; i++; |
and HttpContext.Current.Session["i"] remains 0.
Answers
list
is updated it will reflect in the session. This is a reference type.In the second example you are using a value type:
int i = 0; HttpContext.Current.Session["i"] = i; i++; |
i
and set it to 0 (Value type)You store the value
0
in the session. (Not the memory location of i
)You increment
i
but the session still has the value 0
0 comments :
Post a Comment