Home  /  Questions  /  Question



50   50
Mar 03, 2011


DIfference between IDictionary and Dictionary.

What  is DIfference between IDictionary and Dictionary in terms of implementation.
Please let me know when to use what.





370   99.9
Mar 03, 2011
Hello Pet,

the difference is that Dictionary is concrete implementation while IDictionary is just a contract, abstraction.

It is recommended for example to expect as argument an IDictionary rather that concrete Dictionary, or to expose property of IDictionary rather that Dictionary, because this promotes loose coupling. Than you are able to change underlying objects in the future without affecting those who use your object. 

Hope this wil help.

Best regards,
Robert