Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Newtonsoft.Json;
  4. using System.Reflection;
  5. using System.Runtime.Versioning;
  6.  
  7. namespace JsonSerializeDeserialize
  8. {
  9. public class Test
  10. {
  11. public List<string> Items { get; set; } = new List<string> { "1", "2" };
  12. }
  13.  
  14. class Program
  15. {
  16. static void Main()
  17. {
  18. Console.WriteLine($"Framework={typeof(Program).Assembly.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName?? ""}{Environment.NewLine}");
  19.  
  20. var o = JsonConvert.DeserializeObject<Test>(JsonConvert.SerializeObject(new Test()));
  21. Console.WriteLine($"Count={o.Items.Count}{Environment.NewLine}");
  22.  
  23. o.Items.ForEach(item=> Console.WriteLine(item));
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement