链接并将项添加到另一个类的字典中

时间:2017-02-13 20:28:07

标签: vb.net class dictionary

我有一个字典结构如下:

Public Structure MyStruct
    Dim X as Integer
    Dim Y as Integer
    Dim Z as Integer
    Dim W as Integer
End Structure

Public Shared MyDic As New Dictionary(Of String, MyStruct)

我需要通过另一个类中的函数将一些数据插入到字典中。如何将MyDicMyStruct链接到该类以将数据添加到字典中?

一般情况如下:

Public Class myFirstForm
    Public Structure MyStruct
        Dim X as Integer
        Dim Y as Integer
        Dim Z as Integer
        Dim W as Integer
    End Structure

    Public Shared MyDic As New Dictionary(Of String, MyStruct)
End Class

Public Class myClass
    Public Sub mySub()
        Dim Struct as New MyStruct
        'Some code
        MyDic.Add("FirstElement",Struct)
    End Sub
End Class

1 个答案:

答案 0 :(得分:0)

我解决了这个问题:

GlobalConfigMiddleware.php