94
1
using System;
2
using System.IO;
3
using System.Text;
4
using System.Windows;
5
using System.Xml;
6
using System.Xml.Serialization;
7
8
public class Program
9
{
10
public static void Main()
11
{
12
ResponseBase result1 = Deserialize("<?xml version=\"1.0\"?>\r\n <root>\r\n <elementOne>101</elementOne>\r\n <elementTwo>10</elementTwo>\r\n </root>");
13
ResponseBase result2 = Deserialize("<?xml version=\"1.0\"?>\r\n <root>\r\n <elementOne>101</elementOne>\r\n <elementTwo>10</elementTwo>\r\n <elementThree>10</elementThree>\r\n </root>");
14
15
PrintResult(result1);
16
PrintResult(result2);
17
}
18
19
private static void PrintResult(ResponseBase result)
20
{
21
if(result is DerivedOneClass)
22
{
23
DerivedOneClass derived = (DerivedOneClass)result;
24
Console.WriteLine("Result is of type 'DerivedOneClass': {0}, {1}", derived.ElementOne, derived.ElementTwo);
Cached Result