我有一个带有静态成员的内部静态类 MyLists
internal static ImmutableArray<string> MyList = new ImmutableArray<string> { "asd", "qwe" };
在另一个公共测试类 Tests 中,我有一个 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 为 value = Uninitialized。为什么?