嗨,我正在将VB6迁移到vb.net,并计划将Scripting.Dictionary
替换为Dictionary(Of String, clsAnimal)
。
下面的代码是vb6,它使用Dictionary
Dim clsAni As clsAnimal '(This is a class object)
Dim test As String
Set clsAni = m_dicDemographics.Item(test)
那么如何使用Dictionary(Of String, clsAnimal)
在VB.Net中重写以上内容?
答案 0 :(得分:2)
这是一个完整的示例:
Public Class clsAnimal
' Members go here.
End Class
Module Module1
Dim m_dicDemographics As Dictionary(Of String, clsAnimal) = New Dictionary(Of String, clsAnimal)
Sub Main()
m_dicDemographics.Add("Frog", New clsAnimal())
Dim clsAni As clsAnimal = m_dicDemographics.Item("Frog")
End Sub
End Module