I have some code as follows
var MyObjectInstance = httpContext.Items[key] as MyObject
What overhead is there in this code. Does it need to deserialize the object as well as doing a cast. Is there any significant performance benefit in reducing the number of these calls?
HttpContext.Itemsreally returns aHashTable(in-memory dictionary) – so call such ashttpContext.Items[key] as MyObjectwill essentially has toThere is no deserialization
Performance Benefit will be a relative term – how many times such calls are made? This would be a very fast call, unless you are making thousands of calls in a short time-frame, I would not worry too much about it.