System.Drawing.Color objects apparently won't serialize with XmlSerializer. What is the best way to xml serialize colors?
The simplest method uses this at it's heart:
String HtmlColor = System.Drawing.ColorTranslator.ToHtml(MyColorInstance);
It will just convert whatever the color is to the standard hex string used by HTML which is just as easily deserialized using:
Color MyColor = System.Drawing.ColorTranslator.FromHtml(MyColorString);
That way you're just working with bog standard strings...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With