将arraylist转换为vb.net中的IList

时间:2014-04-23 11:31:00

标签: asp.net-mvc vb.net arraylist

我从控制器那里得到一个arraylist。在视图中,当我尝试显示该数组错误发生时,#34;无法转换类型' System.Collections.ArrayList'输入' System.Collections.Generic.IList`1"。我的代码如下

Dim c As IList(Of myclass) = CType(Model, IList(Of myclass)) (arraylist from controller) 

在模型中有一个arraylist。我不知道如何将这个arraylist演变成IList。请帮忙。感谢

Dim iplist = (From d In db.mytable Select d).ToList
Dim c2 As ArrayList

For i As integer = 0 to iplist.Count - 1
    Dim ip = iplist(i).ip
    Dim c as countrylist
    c.country = country
    c.city = city
Next

Class cou1ntrylist
    Public country As String
    Public city As New ArrayList
End Class

0 个答案:

没有答案