c# store Array collection

Seven price
Seven price used Ask the Experts™
on
is it possible to store array collection in memory and call it later in the code through another method or something.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fernando SotoRetired
Distinguished Expert 2017
Commented:
Well you can define the Array at class level and use it anywhere in your class when you what. Is this what you are asking? If not please be more specific.
Seven priceFull Stack

Author

Commented:
Well. here is the scenario.
to make my life easier for now.
I have a webmethod. submits from the client side first. Then the server side fires off from a button
OnClick="btn_submit_Click"  OnClientClick="Validate();"
so I am trying to retrieve the data hold after the client side submits and reuse it on the server as the postback starts
Fernando SotoRetired
Distinguished Expert 2017
Commented:
A disclaimerI am not a web developer.

You state this, "I have a webmethod. submits from the client side first.", this is what I get out of this. On the server you have a web method most likely part of a web service. The client on his system calls that web method. Is this correct? On what system did the Array get created on, Client or Server? Then on what system you want to store it on Client or Server?
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

Seven priceFull Stack

Author

Commented:
On the client side but need to hold it to pass it to the server side.
You can store your array to session

string[] a = new string[]{"a","b","c"};
Session["values"] = a;

you can retrieve it like this.

string[] a = (string[])Session["values"];
Seven priceFull Stack

Author

Commented:
I try it. but I get
Object reference not set to an instance of an object.
Seven priceFull Stack

Author

Commented:
  [WebMethod(EnableSession = true)]
        [ScriptMethod]
        public static string SubmitInfo(ies[] iesSe)
        {

Open in new window

here is my array that is submmited from the client side alreay. if I could hold iesSe when the serverside is running.
Remember everything is running altogether. There is no stop or pause the client side run then the server side right after.
Seven priceFull Stack

Author

Commented:
thanks guys. these were great solutions. I decided to just convert it all to angularjs using a webmethod. thanks again.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial