Best solution for XmlSerializer and System.Drawing.Color

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…

Leave a Comment