((List<string>)Session["answera"]).Add(xle.InnerText);
I need to perform this operation, but I get “Object reference not set to an instance of….”
I don’t want to use
List<string> ast = new List<string>();
ast.Add("asdas!");
Session["stringList"] = ast;
List<string> bst = (List<string>)Session["stringList"];
as I merely want to add a string to the Session-String-Array.
If you’re getting a null reference exception, it’s because either the session doesn’t contain the list like you think it does, or “xle” is null. Is there any reason you think the session already contains your list?