Let's say I have these byte
s:
byte red = 0;
byte green = 0;
byte blue = 255;
And I want to turn it into the six-character string hex representation you see in CSS (e.g. "#0000ff
"):
How can I do this?
Color c = Color.FromArgb(red, green, blue);
var hexColor = System.Drawing.ColorTranslator.ToHtml(c);
should produce "0000FF"
See MSDN
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With