title: Saving objects with constructor to xml
body: <p>Hello everyone i need some help what do i need to change in this code to be able to serialize (save) this file?
  I'm trying to create a inventory file that will save crafted items (this one in particular saves crafted components) i have a almost identical code for saving crafted weapons. Searching the net i couldn't find a way to serialize this object because it uses parameters, but i need to add data into that list and save it. Is there a way around it ? if yes how ? THANK YOU !</p>
  
  <p>the error im getting is </p>
  
  <p><strong>InvalidOperationException: ComponentDB.ItemEntry cannot be serialized because it does not have a parameterless constructor.</strong></p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using System.Xml;
  using System.Xml.Serialization;
  using System.IO;
  using System;
  using System.Linq;
  
  public class ComponentDB : MonoBehaviour
  {
  
      public ItemDatabase itemDB;
      public string Slot;
      public static ComponentDB ins;
  
      void Awake()
      {
          ins = this;
          Slot = "Slot1";
      }
  
      public void SaveItems()
      {
          XmlSerializer serializer = new XmlSerializer(typeof(ItemDatabase));
          FileStream stream = new FileStream(Application.dataPath + "/StreamingAssets/Save/" + Slot + "CraftedComp.xml", FileMode.Create);
          serializer.Serialize(stream, itemDB);
          stream.Close();
      }
      public void LoadItems()
      {
          XmlSerializer serializer = new XmlSerializer(typeof(ItemDatabase));
          FileStream stream = new FileStream(Application.dataPath + "/StreamingAssets/Save/" + Slot + "CraftedComp.xml", FileMode.Open);
          itemDB = serializer.Deserialize(stream) as ItemDatabase;
          stream.Close();
      }
  
      [Serializable]
      public class ItemEntry
      {
          public string Name;
          public string Data;
          public int Amount;
  
  
          public ItemEntry(string iName, string idata, int iAmount)
          {
              Name = iName;
              Data = idata;
              Amount = iAmount;
          }
      }
  
      [Serializable]
      public class ItemDatabase
      {
          public List&lt;ItemEntry&gt; list = new List&lt;ItemEntry&gt;();
      }
  
      public void ManageItemsInv(string input_name, string input_list,  int input_amount)
      {
  
          ins.itemDB.list.Add(new ItemEntry(input_name, input_list,  input_amount));
      }
  }
  </code></pre>