2
這裏是我的類Json.Net序列化數組和反序列化作爲一個列表
public class Agency
{
private IList<AgencyCommission> _commission;
public Agency()
{
_commission = new List<AgencyCommission>();
}
public string Name {get; set;}
public AgencyCommission[] Commissions
{
get {return _commissions.ToArray();}
private set {_commissions = value;}
}
public void ComissionAdd(AgencyCommission commission)
{
if (commission != null)
{
_commissions.Add(commission);
}
}
}
序列化,然後反序列化它完美的作品,直到我嘗試添加一個新的委員會,它吹一個錯誤說:
System.NotSupportedException : Collection was of a fixed size.
at System.SZArrayHelper.Add(T value)
at Agency.ComissionAdd(AgencyCommission commission) in Agency.cs: line 62
如何使這項工作?定製轉換器?自定義解析器?
任何示例代碼高度讚賞!