I am searching for .NET copy-on-write collections to use in C# programs, such as List, Dictionary, etc. Which collections have that property?
A . NET collection is a set of similar type of objects that are grouped together. System. Collections namespace contains specialized classes for storing and accessing the data.
Include the reference FSharp.Core. And then you have access to many kinds of collections which is immutable (Set, List, Map etc.)
These are located in Microsoft.FSharp.Collections.
Example:
var map = MapModule.Empty<string, int>(); var newMap = map.Add("key", 1); You probably want to define some extension methods so you can call directly on map.
Update: The BCL team is working on immutable collections as mentioned in the other answer which makes this partly obsolete. F# collections can still be used, but BCL collections have a more C# feel to them.
Direct link to Nuget package: Immutable Collections
.NET just shipped their first copy-on-write collections, which I suggest you try out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With