I believe you should be able to do it directly using the XmlSerializer, you will not be able to deserialize it though.
If you need to deserialize it, you will need to handle-code a serializer for it. -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of James Berry Sent: Wednesday, September 06, 2006 9:56 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: [ADVANCED-DOTNET] XmlSerialization of immutable objects Given an immutable class, I would like to use Xml Serialization to persist and recover this object. It looks at first glance like Xml Serialization would require public setters for "A" and "B", which I am trying to avoid. Is there a good technique I can use? Or do I need to override the serialization? (This is quite a complex object graph in my real world example so I'd like to do it as simply as possible). public class Test { public Test(string a, string b) { this.a = a; this.b = b; } string a; string b; public string A { get { return a; } } public string B { get { return b; } } } Best wishes James =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com