What I have is R:255 G:181 B:178, and I am working in C# (for WP8, to be more specific)
I would like to convert this to a hex number to use as a color (to set the pixel
Using string interpolation, this can be written as:
$"{r:X2}{g:X2}{b:X2}"
Try the below:
using System.Drawing;
Color myColor = Color.FromArgb(255, 181, 178);
string hex = myColor.R.ToString("X2") + myColor.G.ToString("X2") + myColor.B.ToString("X2");
Greetings fellow humans,
//Red Value
int integerRedValue = 0;
//Green Value
int integerGreenValue = 0;
//Blue Value
int integerBlueValue = 0;
string hexValue = integerRedValue.ToString("X2") + integerGreenValue.ToString("X2") + integerBlueValue.ToString("X2");
You can use ColorHelper library for this:
using ColorHelper;
RGB rgb = new RGB(100, 0, 100);
HEX hex = ColorConverter.RgbToHex(rgb);
You can use a shorter string format to avoid string concatenations.
string.Format("{0:X2}{1:X2}{2:X2}", r, g, b)