今天用到要将颜色值转换成对应的十六进制值
具体方法如下:
int r = foreColor.R;//红色分量
int g = foreColor.G;//绿色分量
int b = foreColor.B;//蓝色分量
string strRed = String.Format("{0:X2}", r);//红色分量的十六进制字符串
string strGreen = String.Format("{0:X2}", g);
string strBlue = String.Format("{0:X2}", b);
string output = "<font style='color:" + strRed + strGreen + strBlue + "'>" + text + "</font>";