Serialize an immutable collection

September 7, 2025 ยท View on GitHub

This sample serializes an immutable collection into JSON.

var l = ImmutableList.CreateRange(
[
    "One",
    "II",
    "3"
]);

var json = JsonConvert.SerializeObject(l, Formatting.Indented);
// [
//   "One",
//   "II",
//   "3"
// ]

snippet source | anchor