c# – Dictionary<KeyType,ValueType> is it thread safe for reading?


Is Dictionary<KeyType,ValueType> thread-safe for reading and iterating over values?

That is, there will be no entry in this Dictionary (it is initialized only when the project is launched), and I want to understand whether it can be used in the context of a singleton service in ASP.NET Core 2.0?



thread safety

A Dictionary can support multiple readers concurrently, as long as the collection is not modified.

that is

thread safety

…supports multiple concurrent reads, as long as the data doesn't change.

Scroll to Top