Click to See Complete Forum and Search --> : Getting Array From Session()


ajr
February 14th, 2001, 03:25 PM
Hi,

I´m putting a array of 2 dimension on Session() object with
dim myarray(3,6)
Session("myarray") = myarray


When I retrieve the array with

myarray = Session("myarray")


and test it with vartype() I get code 8 (note array) and with typename(array) I get a string sub type.

And if I trie to get UBound(array), I get type mimatch.

How can I correct it?

saurabhN
February 15th, 2001, 11:30 AM
Hi am a C# programer , so I dont know the excat VB code but, the problem ur facing is that when you insert a Array inside a Session it gets stored as a Object, so to Get back the Array you have to "Type Cast" explictly the Object
eg : in C#
int[,] myArray = new int[3,6] ;
Session["myArray"] = myArray ;
//now to get the Array back
int[,] newArray = (int[,])Session["myArray"] ;

The(int[,]) type casts the Object back to a Array

Hope this helps

Saurabh Nandu
mailsaurabhn@webveda.com
http://Learncsharp.cjb.net