How to save an array in a session in ASP.NET MVC?

Could you tell me how to store an array in a session and how to extract this array from a session?

I try to save one array of type Double and assign values ​​of the same type, but it shows me an error. How to assign values ​​to an array that is in a session?

I am using ASP.NET MVC .

+6
asp.net-mvc
source share
2 answers
  Session["your_array"] = new double[]{1.0,2.0,3.0}; double[] arr = double[](Session["your_array"]); 
+7
source share

You have probably developed how to get a double array, but may have some problems returning them - here are examples of both:

  double[] myDoubleArray = new double[] { 1.0, 1.2, 1.3, 1.4}; Session["DoubleList"] = myDoubleArray; double[] sessionDoubles = (double[])Session["DoubleList"]; 
+6
source share

All Articles