Help with Hashtable Iteration
Ok, I have always been able to iterate though a hashtable with the "Option Strict turned Off" but after someone suggesting I should code with it ON for good practice reasons, Now I'm running into problems Iterating though a Hashtable that I store a Class object in..
The old way worked fine..
Code:
Dim en As IDictionaryEnumerator = HashTest.GetEnumerator
With lstID
.BeginUpdate()
.Items.Clear()
While en.MoveNext
Dim R As clsTest = en.Value
.Items.Add(R.MyID)
End While
.EndUpdate()
End With
Now that I have turned Option Strict on, it bugs out, I get an error that says..
Option Strict On disallows implicit conversions from 'System.Object' to 'Hashing.clsTest'.
which applies to this:
Code:
Dim R As clsTest = en.Value
I have tried to cast it by doing
Code:
Dim R As clsTest = CType(en.Value, clsTest)
But it won't let me cast it to that class type..
Does anyone know what I need to do in order to do this?