Gyn*_*tot 1 c# immutable-collections
我正在尝试像常规列表一样初始化不可变的列表,但它告诉我它不接受0参数。如果我传递1个参数,2个参数等,则会引发相同的错误。
public static readonly ImmutableList<object[]> AddressTestCases = new ImmutableList<object[]>
{
new object[]{ "", false },
new object[]{ "testestest", true },
};
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?有没有一种方法可以不使用.Add?
好的ImmutableList有一个您应该使用的创建方法
public ImmutableList<int> ImmutableListCreate()
{
return ImmutableList.Create<int>(1, 2, 3, 4, 5);
}
Run Code Online (Sandbox Code Playgroud)