Can't get a List(Of <my class>) from a Dictionary in .NET?

Posted by magsto on Stack Overflow See other posts from Stack Overflow or by magsto
Published on 2010-06-11T13:32:39Z Indexed on 2010/06/11 13:43 UTC
Read the original article Hit count: 155

Filed under:
|
|

I have a Dictionary with key of type UInteger and the value is List(Of Session) where the (Public) class Session contains a couple of variables and a constructor (Public Sub New(...)).

Some of the variables in my Session class is:

Private count As Integer
Private StartDate As Date
Private Values As List(Of Integer)

and a couple of methods like:

Friend Sub Counter(ByVal c as Integer)
    count += c
End Sub

There is no problem to add values to the Dictionary:

Dim Sessions As New List(Of Session)
Dim dict As New Dictionary(Of Integer, Sessions)

then some code to fill up a couple of Session objects in Sessions (not shown here) and then:

dict.Add(17, Sessions) 'No problem
Sessions.Clear()
Sessions = dict(17) 'This doesn't return anything!

The Sessions object is empty even if the code doesn't returned any error. Is my class Session to compex to be stored in a Dictionary?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about list