How to store SortedList in Session or Cache.

vishalneeraj-24503
Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 1238
Import System.Collections namespace at the top of .cs or .vb page as

Imports System.Collections

Dim lst As New SortedList()
lst.Add("Key1","ValueA")
lst.Add("Key2","ValueB")
Session("SortedList") = lst

'To convert Session again into SortedList,we will write below code:-
Dim sort_lst_obj As SortedList = CType(Session("SortedList"),SortedList)

'To access value from SortedList
Dim str_value1 As String = sort_lst_obj("Key1")
Dim str_value2 As String = sort_lst_obj("Key2")

Comments or Responses

Login to post response