Yes, you can store the values in Application state. Application state stores the value in Object type. So, you can store any kind of data in the state. Provided that you properly cast it back to the actual type. Like this,
string[] stringArray = { "Afzaal", "Ahmad", "Zeeshan" };
Application["StringArray"] = stringArray;
For more on storing the values in Application state please read:
https://msdn.microsoft.com/en-us/library/94xkskdf(v=vs.140).aspx[
^]
Now when you want to extract the values, you simply use this...
if(Application["StringArray"] != null) {
string[] stringArray = (string[])Application["StringArray"];
string surname = stringArray[2];
}
For more on extracting the values from Application state please read:
https://msdn.microsoft.com/en-us/library/y8hhek39(v=vs.140).aspx[
^]
Checking if the key/value pair exists or not doesn't cost a fortune. But will surely protect you from
NullReferenceException
. Then, you can cast the value to the proper type (
which so ever type it is... Even custom types such as
class
or
struct
etc.). They would work. :-)