Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Runtime.Serialization;
- using System.IO;
- namespace SerializingTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- Brazier[] braziers = { new LinearBrazier() };
- var ser = new DataContractSerializer(typeof(Brazier[]));
- using (var stream = new MemoryStream())
- {
- ser.WriteObject(stream, braziers);
- Console.WriteLine(Encoding.ASCII.GetString(stream.ToArray()));
- }
- Console.ReadKey();
- }
- }
- [Serializable]
- [KnownType("GetKnownType")]
- public class Brazier
- {
- private static Type[] GetKnownType()
- {
- Type[] t = new Type[1];
- t[0] = typeof(LinearBrazier);
- return t;
- }
- }
- [Serializable]
- public class LinearBrazier : Brazier
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement