I stumbled at the very beginning, I can not initialize the list, apparently due to the fact that the list is unchangeable. How to work with it? How to assign an array to it?
ImmutableList<int> firstList = new ImmutableList<int>(); I stumbled at the very beginning, I can not initialize the list, apparently due to the fact that the list is unchangeable. How to work with it? How to assign an array to it?
ImmutableList<int> firstList = new ImmutableList<int>(); Here is an example of creating
var builder = ImmutableList.CreateBuilder<string>(); builder.Add("1"); // Adds item to the existing object ImmutableList<string> list = builder.ToImmutable(); ImmutableList<string> list2 = list.Add("2"); // Creates a new object with 2 items Taken from here
Another option:
int[] data = {1, 2, 3}; ImmutableList<int> firstList = ImmutableList.CreateRange(data); or so:
int[] data = {1, 2, 3}; var firstList = data.ToImmutableList(); Source: https://ru.stackoverflow.com/questions/726278/
All Articles