In C#, you can use the object/collection initialization syntax like this:
The F# equivalent of object initialization is done like this:
As for collection initialization, you have a far more diverse range of tools available to you, for example:
You can also create slices of an existing array:
You can even add your own multi-dimensional indexers to support similar behaviours in your type too!
As Robert Pickering mentioned in the comments, slicing is not limited to arrays, it works with other collection types too (as long as a GetSlice extension method is defined on the type, for more information, see here). For instance, you can use slicing on a string like this:
With 2D arrays, you can also use a multi-dimensional slicer too:
Subscribe to my newsletter and get new contents delivered straight to your inbox :-)