What is the difference between dictionary (Of String, String) and IDictionary (Of String, String)

Is it possible to do something more or less with an IDictionary? How do these two collections differ?

+3
source share
6 answers

IDictionary is just an interface — a contract that describes what an implementation class should do. A dictionary is a concrete class that implements this interface and, therefore, should provide the methods described in the IDictionary interface.

If you want to create a dictionary, you must create a specific class (for example, a dictionary), but if all you want to do with this dictionary is the methods open by the IDictionary interface, you can pass the concreate round class as an interface that reduces the connection between methods.

+8

, , IDictionary(Of String, String) - , Dictionary(Of String, String) - , . , .

, , ; , emtpy. , .NET Dictionary :

Function GetValueFromKey(ByVal dict As Dictionary(Of String, String),
                         ByVal key As String) As String
    If ''//you find the value in the dictionary
         return theValue
    Else ''//you can't find the value in the ditionary
         return String.Empty
    End If
End Function

, . , . , , .NET Dictionary , 50 000 (. , - .NET Dictionary, ), 50 000 .

, .NET Dictionary. , , GetValueFromKey(...), . , , , .

GetValueFromKey, , , : " . , , ". IDictionary :

Function GetValueFromKey(ByVal dict As IDictionary(Of String, String),
                         ByVal key As String) As String
    If ''//you find the value in the dictionary
         return theValue
    Else ''//you can't find the value in the ditionary
         return String.Empty
    End If
End Function

, , Dictionary IDictionary? ? № IDictionary - , , . . , .

, IDictionary Dictionary, , , , IDictionary. , IDictionary, , , .

" , " . , , .

+6

IDictionary - - . - IDictionary, , IDictionary , , .

, , , IDictionary.

+1

, Dictionary<TKey, TValue> - , IDictionary<TKey, TValue>.

, , :)

0

(Of String, String) - IDictionary (Of String, String).

Dictionary (Of String, String), Dictionary (Of String, String) . IDictionary (Of String, String), , IDictionary (Of String, String), Dictionary (Of String, String).

, , , .

0

, , IDictionary<TKey, TValue> - , , IDictionary .

, IDictionary `Dictionary

Here , IDictionary.

, Dictionary , IDictionary. , , Dictionary , IDictionary

However, according to this documentation IDictionary , it takes longer than Dictionarybecause the author showed some real-time execution of It.

0
source

Source: https://habr.com/ru/post/1786139/


All Articles