Session String[] Array?

Q. How do I send & recieve a string[] in a Session?

string[] names = new string[3] {"Matt", "Joanne", "Robert"};

Session("nameArray") = names???
pointemanAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Umar TopiaConnect With a Mentor .Net Full Stack DeveloperCommented:
You can store anything in Session Varibale

However, while retrieving you will have to cast it in specific Type

string[] names = new string[3] {"Matt", "Joanne", "Robert"};

string[] strarrSessionNames = Session("nameArray") as string[];

or

string[] strarrSessionNames = (string[])(Session("nameArray"));
0
 
Umar Topia.Net Full Stack DeveloperCommented:
for storing it's a simply statement

string[] names = new string[3] {"Matt", "Joanne", "Robert"};

Session["nameArray"] = names;
0
 
pointemanAuthor Commented:
Okay, then access the info like:

string matt  = names[0].ToString();
string joanne  = names[1].ToString();
0
 
Umar Topia.Net Full Stack DeveloperCommented:
Yeah... once you get the array object
then you can play around with it in normal way
0
 
pointemanAuthor Commented:
thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.