fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace expirement
  8. {
  9. public class Box
  10. {
  11. public int x;
  12. public Box(int a)
  13. {
  14. x = a;
  15. }
  16. public Box()
  17. {
  18. }
  19. }
  20.  
  21. public class Program
  22. {
  23. static void Main(string[] args)
  24. {
  25. List<Box>[] MainArr = new List<Box>[1];
  26. MainArr[0] = new List<Box>();
  27. Box Box1 = new Box(1);
  28. MainArr[0].Add(Box1);
  29. System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(MainArr.GetType());
  30. MemoryStream output = new MemoryStream();
  31. StreamWriter sw = new StreamWriter(output);
  32. writer.Serialize(sw, MainArr);
  33. sw.Close();
  34. var data = output.GetBuffer();
  35. output.Close();
  36. Console.WriteLine("Size: " + data.Length);
  37.  
  38. StreamReader rw = new StreamReader(new MemoryStream(data));
  39. var result = (List<Box>[])writer.Deserialize(rw);
  40. Console.WriteLine("Result: " + result[0].First().x);
  41.  
  42. }
  43. }
  44. }
Success #stdin #stdout 0.24s 41024KB
stdin
Standard input is empty
stdout
Size: 256
Result: 1