Live Chat Icon For mobile
Live Chat Icon

How to store SortedList in Session or Cache

Platform: ASP.NET| Category: Session

VB.NET


Dim x As New SortedList()
x.Add('Key1', 'ValueA')
x.Add('Key2', 'ValueB')

To store in Session:


Session('SortedList1') = x 

and to retrieve


Dim y As SortedList = CType(Session('SortedList1'), SortedList)

C#


SortedList x = new SortedList();
x.Add('Key1', 'ValueA');
x.Add('Key2', 'ValueB');

To store in Session:


Session['SortedList1'] = x;

and to retrieve


SortedList y = (SortedList) Session['SortedList1'];

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.