Tutorial :object to byte not working



Question:

I am trying to convert class to byte but not worked.

I receive a byte[] (b) with zero length . why ?

void start()  {        Item item = new Item();      item.files.Add(@"test");      byte[] b = ObjectToByteArray(item);  // b will have zero length     }          [Serializable]      public class Item : ISerializable      {          public Item()          {              files = new List<string>();              Exclude = false;              CleanEmptyFolder = false;          }          public List<string> files;          public string MusicProfileName;          public bool Exclude;            #region ISerializable Members            public void GetObjectData(SerializationInfo info, StreamingContext context)          {              info.AddValue("files", files);              info.AddValue("MusicProfileName", MusicProfileName);              info.AddValue("Exclude", Exclude);          }            





        
Previous
Next Post »