6

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
  • 1
    It would undoubtedly help us to help you if you gave details of the error that is being shown. Commented Mar 12, 2010 at 8:43

2 Answers 2

9
    Session["your_array"] = new double[]{1.0,2.0,3.0};


 double[] arr = double[](Session["your_array"]);
Sign up to request clarification or add additional context in comments.

Comments

6

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"];

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.