2

Here is my class

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);
        }
    }
}

Serializing it and then deserializing it works perfectly, until I try to add a new commission, it blows an error saying:

System.NotSupportedException : Collection was of a fixed size.
at System.SZArrayHelper.Add(T value)
at Agency.ComissionAdd(AgencyCommission commission) in Agency.cs: line 62

How to make this works ? Custom converter ? Custom Resolver ?

Any sample code highly appreciated !

1 Answer 1

2

I found a solution to this:

public AgencyCommission[] Commissions
{
   get {return _commissions.ToArray();}
   private set {_commissions = new List<AgencyCommission>(value);}
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.