System.Drawing.Color to String

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

How do I convert a property of System.Drawing.Color to a string, i.e.,
"#FFFFFF"?

I have the following but it is not working:
MyColor.ToString

Thanks,
Miguel
 
How do I convert a property of System.Drawing.Color to a string, i.e.,
"#FFFFFF"?

I have the following but it is not working:
MyColor.ToString

There may be a built-in way, but I use this:

private string ColorToHex(Color pobjColor)
{
return "#" + string.Format("{0:X2}{1:X2}{2:X2}", pobjColor.R,
pobjColor.G, pobjColor.B).ToLower();
}
 
Back
Top