有时需要在数据库中存储色彩信息,并在需要的地方动态使用,下面的代码就用得上了
C#代码如下:
string c1 = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.Red); //颜色转字符串
System.Drawing.Color c2 = System.Drawing.ColorTranslator.FromHtml("#ff0000"); //字符串转颜色
有时需要在数据库中存储色彩信息,并在需要的地方动态使用,下面的代码就用得上了
C#代码如下:
string c1 = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.Red); //颜色转字符串
System.Drawing.Color c2 = System.Drawing.ColorTranslator.FromHtml("#ff0000"); //字符串转颜色