我正在尝试像常规列表一样初始化不可变列表,但它告诉我它不需要 0 个参数。如果我传递 1 个参数、2 个参数等,它会抛出相同的错误。
public static readonly ImmutableList<object[]> AddressTestCases = new ImmutableList<object[]>
{
new object[]{ "", false },
new object[]{ "testestest", true },
};
我在这里做错了什么?有没有办法不使用 .Add 来做到这一点?
最佳答案
好的 ImmutableList 有一个你应该使用的创建方法
public ImmutableList<int> ImmutableListCreate()
{
return ImmutableList.Create<int>(1, 2, 3, 4, 5);
}
关于c# - ImmutableList 不包含采用 0 个参数的构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50820394/