【发布时间】:2020-12-13 02:48:46
【问题描述】:
我正在尝试初始化一个嵌套类,下面是嵌套类。
public class Msg
{
[JsonProperty("to")]
public ToObj to { get; set; }
[JsonProperty("from")]
public FromObj from { get; set; }
[JsonProperty("timestamp")]
public string timestamp { get; set; }
[JsonProperty("message")]
public MessageObj message { get; set; }
public class ToObj
{
[JsonProperty("type")]
public string type { get; set; }
[JsonProperty("id")]
public string id { get; set; }
[JsonProperty("number")]
public string number { get; set; }
}
public class FromObj
{
[JsonProperty("type")]
public string type { get; set; }
[JsonProperty("id")]
public string id { get; set; }
[JsonProperty("number")]
public string number { get; set; }
}
}
我每次都需要初始化每个类吗?或任何其他方式来初始化嵌套类。请告诉我
【问题讨论】: