Как создать общую переменную для каждого унаследованного класса? - PullRequest
0 голосов
/ 12 мая 2019

Скажите, что Base - это базовый класс

Мне нужна общая переменная для всех классов, производных от Base. Однако у каждого производного класса есть своя общая переменная.

Это как это реализовать?

Private Shared _tableOfCurrencyDictionary As Dictionary(Of String, Dictionary(Of String, BaseQuoteandBaseQuote))

Protected Property _tableOfCurrency As Dictionary(Of String, BaseQuoteandBaseQuote)
    Get
        Dim className = Me.GetType().Name
        If _tableOfCurrencyDictionary.ContainsKey(className) Then
            Return _tableOfCurrencyDictionary(className)
        Else
            Return Nothing
        End If
    End Get
    Set(value As Dictionary(Of String, BaseQuoteandBaseQuote))
        Dim className = Me.GetType().Name
        _tableOfCurrencyDictionary(className) = value
    End Set
End Property

Есть ли лучшие способы?

...