아래 예제는 Generic Dictionary의 XML Serialization 가능 여부를 시험해 보기 위해서 만든 것이다.
결과는 Exception이 발생했다.
Generic Dictionary 타입은 지원하지 않는다는 메세지가 나왔다.
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
namespace SerializationTest
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, int> myDictionary = new Dictionary<string, int>();
myDictionary["One"] = 1;
myDictionary["Two"] = 2;
XmlSerializer myXmlSerializer = new XmlSerializer(typeof(Dictionary<string, int>));
using (XmlWriter writer = XmlWriter.Create("serialization.xml"))
{
myXmlSerializer.Serialize(writer, myDictionary);
}
}
}
}
결과는 Exception이 발생했다.
Generic Dictionary 타입은 지원하지 않는다는 메세지가 나왔다.
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
namespace SerializationTest
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, int> myDictionary = new Dictionary<string, int>();
myDictionary["One"] = 1;
myDictionary["Two"] = 2;
XmlSerializer myXmlSerializer = new XmlSerializer(typeof(Dictionary<string, int>));
using (XmlWriter writer = XmlWriter.Create("serialization.xml"))
{
myXmlSerializer.Serialize(writer, myDictionary);
}
}
}
}
'Show' 카테고리의 다른 글
| 인텔 칩셋 비교 (G31, G33, P31, P35) (0) | 2007.12.23 |
|---|---|
| XmlSerializer의 버그? TimeSpan 클래스를 못 다루는 문제 (0) | 2007.12.16 |
| Visual C# 2005 단축키 (shortcuts) (0) | 2007.12.11 |
| C# & .NET , BCL에 대한 단상 (0) | 2007.12.09 |
| 단위 : Power Prefixes (0) | 2007.12.09 |