I want to save some strings in a Session("myKey")
as an ArrayList in my asp.net application.
So I have somthing like that:
Dim s As String = "String1"
If I use
Session("myKey") = s
it is working for the moment.
After PostBack I want to add another string to the session.
If do the same thing again, then i will overwrite my Sessiondata.
So I'm searching for something like this:
Dim s As String = "String1"
TryCast(Session("myKey"), ArrayList).Add(s)
In this case the Sessiondata would be stored correctly, but my code is not correct.
I've tried and found a solution by myself;
Dim s As String = "String1"
If Session("myKey") Is Nothing Then
Session("myKey") = New ArrayList
End If
TryCast(Session("myKey"), ArrayList).Add(s)
Don't know if it is the usual way, but it is working.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.