An Elegant Way to Implement ReadOnlyDictionary<TKey, TValue> in C#

added by softwarerockstar
10/30/2010 1:35:42 AM

0 Kicks, 63 Views

While working on creating an application framework for a personal project, I needed a way to expose a Dictionary<TKey, TValue> object from one of my methods. The only caveat being, I wanted the Dictionary object to be read-only. I knew that there exists a ReadOnlyCollection<T> in the FCL, but to my dismay there is no built-n way of creating a read-only Dictionary in .NET.