我是C#和WPF的新手。我有一个课程和其他嵌套课程。
class jsonConfig
{
public obj_info info { get; set; }
public string server { get; set; }
public string status { get; set; }
public string workstation { get; set; }
public Boolean transmite_data { get; set; }
public class obj_info
{
public string System { get; set; }
public string application { get; set; }
public string version { get; set; }
public DateTime build_date { get; set; }
}
}
,当我尝试为“ jConfig.info”下的任何对象分配值时。我收到一个错误: “对象引用未设置为对象的实例”
jsonConfig jConfig = new jsonConfig();
jConfig.info.System = "ROSS";
jConfig.info.application = "WatchDog";
jConfig.info.version = "2.0.0";
jConfig.info.build_date = new DateTime(2019,01,08);
jConfig.server = "https://ross.client.com";
jConfig.status = "Connected";
jConfig.transmite_data = false;