Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using Newtonsoft.Json;
- using System.Reflection;
- using System.Runtime.Versioning;
- namespace JsonSerializeDeserialize
- {
- public class Test
- {
- public List<string> Items { get; set; } = new List<string> { "1", "2" };
- }
- class Program
- {
- static void Main()
- {
- Console.WriteLine($"Framework={typeof(Program).Assembly.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName?? ""}{Environment.NewLine}");
- var o = JsonConvert.DeserializeObject<Test>(JsonConvert.SerializeObject(new Test()));
- Console.WriteLine($"Count={o.Items.Count}{Environment.NewLine}");
- o.Items.ForEach(item=> Console.WriteLine(item));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement