tags:

views:

100

answers:

2

Can you please tell me how to store an array in session and how to retrieve that array from session?

I am trying to store one array of type Double and assigning values of the same type but it is showing me an error. How do I assign values to the array which is in session?

I am using ASP.NET MVC.

+1  A: 
    Session["your_array"] = new double[]{1.0,2.0,3.0};


 double[] arr = double[](Session["your_array"]);
chugh97
A: 

You have probably worked out how to get the double array in, but may be having some trouble getting them back out - so 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"];
Sohnee
thank you so much i implemented it thanks but my problem was that i am using seprate class for session variables and accessing data from there but any way i will implement it. thanks
mary