标签:bubuko oid com test ado hive var alt pac
namespace test { class Program { static void Main(string[] args) { var zoo1 = new zoo(); zoo1.animals = new List<animal>(); zoo1.animals.Add(new cat() { Name = "hello kitty", legs = 4 }); zoo1.animals.Add(new dog() { Name = "dog1", tail = true }); string json= fastJSON.JSON.Instance.ToJSON(zoo1); //序列化 var z = fastJSON.JSON.Instance.ToObject<zoo>(json); //反序列化 Console.WriteLine(z.animals[0].Name); Console.Read(); } } public class animal { public string Name { get; set; } } public class cat : animal { public int legs { get; set; } } public class dog : animal { public bool tail { get; set; } } public class zoo { public List<animal> animals { get; set; } }
https://www.cnblogs.com/hjblog/archive/2012/11/19/2776869.html
标签:bubuko oid com test ado hive var alt pac
原文地址:https://www.cnblogs.com/zhaogaojian/p/9026390.html