我有一个内部静态类MyLists具有静态构件静态ImmutableArray未初始化
internal static ImmutableArray<string> MyList = new ImmutableArray<string> { "asd", "qwe" };
在另一个公共测试类测试我有选择并比较该列表中MyTest的功能。我得到一个
Additional information: The type initializer for 'TestMyLists' threw an exception.
Object reference not set to an instance of an object.
[TestClass]
public class MyTests {
[TestMethod]
public void TestMyLists() {
var list = MyLists.MyList.Select(s => s + ".foo");
}
}
当我调试我看到静态ImmutableArray为值=未初始化。为什么?
od Lists或Lists.List的值是什么? – Jacek
这里列出了什么?这不是一个很好的做法,可以将您的局部变量命名为预定义的变量。例如:列表 –
我认为你应该使用工厂方法来创建ImmutableArray –