Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

asp.net

vb.net

Can I do anything more or less with IDictionary? How do these two collections differ?

like image 529
Kevin Avatar asked Dec 03 '22 09:12

Kevin


1 Answers

IDictionary is only an interface - a contract which describes what an implementing class must do. Dictionary is a concrete class that implements that interface and hence must provide the methods described in the IDictionary interface.

If you want to create a dictionary you must create a concrete class (i.e. Dictionary), but if all you want to do with that dictionary is methods exposed by the IDictionary interface you can pass the concreate class round as an interface - which reduces the coupling between methods.

like image 87
Jackson Pope Avatar answered Dec 22 '22 00:12

Jackson Pope