C# Color Font 与String之间的转换

因为项目要保存本地化配置 我用Xml保存的,所以要把背景色 字体设置转换成字符串

Color与String之间的转换


string colorValue = ColorTranslator.ToHtml(Color.Red); Color c = ColorTranslator.FromHtml(colorValue);

Font与String之间的转换

FontDialog fd = new FontDialog();
            fd.ShowDialog();
            FontConverter fcs = new FontConverter();
            string f = fcs.ConvertToInvariantString(fd.Font);
            Font font = fcs.ConvertFromInvariantString(f) as Font;
原文地址:https://www.cnblogs.com/sulei4471/p/2848793.html