0

I'm sorry if it looks stupid, but I really can`t understand how to serialize my own class which has property:

public Encoding EncodingName {get;set;}.

Can someone explain what is the best way to solve my problem?

okk
  • 420
  • 5
  • 7
  • Well, is "Encoding" a serializable class? Have you read about the ISerializable interface? – LightStriker Apr 16 '13 at 10:21
  • What is the problem? `System.Text.Encoding` is marked as `Serializable`. – John Willemse Apr 16 '13 at 10:22
  • When i`m trying to create XML file it throws error "Error when creating document", but if I put [XMLIgnore] before "encodingname" property it works well. – okk Apr 16 '13 at 10:26
  • 1
    How about adding another property to your class `public int CodePage { set { EncodingName = Encoding.GetEncoding(value); } get { return EncodingName.CodePage;} }` and mark `EncodingName` with `[XmlIgnore]` – I4V Apr 16 '13 at 10:30
  • L4V, thanks for your help. Because of lack of experience and tiredness I missed this option.. – okk Apr 16 '13 at 10:36

0 Answers0