Q:

ASP.net, adding objects to a session variable

I'm trying to add an object(s) to a session variable across postbacks.   My code looks similar to the following. 
  Supply sup =  Supplies. GetSupply(supplyItemID);

  Session["CartObjects"] += sup;

Now, the compiler throws an error saying that the "+=" operator cannot be used on type 'object' and 'Supply'.   Do I need to implement an interface on my Supply object that allows it to be added?   Is this possible or am I thinking about this in the completely wrong way. 

A:

Try this:
Supply sup =  Supplies. GetSupply(supplyItemID); 
var cartObjects =  (Session["CartObjects"] as List<Supply>) ??  new List<Supply>();
cartObjects. Add(sup);
Session["CartObjects"] = cartObjects;

A:

unless you are trying to create some sort of array the syntax is just
Session["CartObjects"] = sup;

