Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将 RGB 字符串转换为十六进制颜色代码。例如 :
string rgb = rgb(0, 0, 255);
从上面的RGB我想得到:
string hex = #0000FF;
使用内置的ColorTranslator.ToHtml
string hex = ColorTranslator.ToHtml(myColor);
简直就是这样
string hex = "#" + rgb.R.ToString("X2") + rgb.G.ToString("X2") + rgb.B.ToString("X2");