C# 获得;类型初始化异常";
我在下一行收到类型初始化异常C# 获得;类型初始化异常";,c#,asp.net,unit-testing,C#,Asp.net,Unit Testing,我在下一行收到类型初始化异常 var path = InputOptions.downloadsPath; InputOptions是我编写的一个类。其中包括: public static readonly string parentpath = Directory.GetParent(Directory.GetCurrentDirectory()).ToString(); public static readonly string downloadsPath = parentpath + @
var path = InputOptions.downloadsPath;
InputOptions
是我编写的一个类。其中包括:
public static readonly string parentpath = Directory.GetParent(Directory.GetCurrentDirectory()).ToString();
public static readonly string downloadsPath = parentpath + @"\DATA\Download";
为“path”变量赋值时出错。为什么要重新赋值为只读值?这难道不能阻止它成为只读的吗?你问的问题完全不清楚。特别是你的简约代码对再现你的问题没有多大帮助。它甚至不编译。您能提供一个吗?我已经编辑了问题,我没有重新分配值。现在可以理解吗??