Reputation: 1027
I am using a hastable but when i add a value to it i get an error
Value of type '1-dimensional array of System.Collections.Hashtable' cannot be converted to 'System.Collections.Hashtable'
Am i missing missing really basic.
Public Shared Function LstItemsAsHT() As Hashtable()
Dim htStudents As Hashtable = New Hashtable()
Try
Using dbcontext As New Entities
Dim result = From l In dbcontext.students
Where l.Pass = False
Select l
For Each student In result.ToList()
htReceipt.Add(student.Id, student.Type)
Next
End Using
Catch ex As Exception
End Try
Return htStudents
End Function
Upvotes: 0
Views: 282
Reputation: 460340
Your method returns a HashTable()
instead of a single HashTable
. Change it to:
Public Shared Function LstItemsAsHT() As Hashtable
Apart form that, why do you still use a Hashtable
at all if you can use a strong typed Dictionary(Of Int32, String)
? Also, the result.ToList()
is not needed. You can enumerate the sequence immediately without creating a new list first.
Upvotes: 1