...
On May 29, 11:18 pm, "Mark Rae" <m
@markNOSPAMrae.net> wrote:
I want to use the string #FFFFFF in a style. So i need the color in
that format.
So if color is white I need to get "#FFFFFF"
Thanks,
Miguel
-----------------------------------------------Reply-----------------------------------------------
I think this is what you want.
Color color = Color.White;
string hexFormat= string.Format("#{0:X}", color.ToArgb());
Console.WriteLine(hexFormat);
//note: written in C#
--Papanii
"shapper" <mdmo
@gmail.com> wrote in message
news:1180478026.742404.179850@u30g2000hsc.googlegroups.com...
> On May 29, 11:18 pm, "Mark Rae" <m
@markNOSPAMrae.net> wrote:
>> "shapper" <mdmo
@gmail.com> wrote in message
>> news:1180475569.740612.274840@h2g2000hsg.googlegroups.com...
>> > How can I convert a variable of type color to a String where the color
>> > is in the format #FFFFFF?
>> Not quite sure what you're looking for here - what are you expecting the
>> string to contain after the conversion...?
>> --http://www.markrae.net
> I want to use the string #FFFFFF in a style. So i need the color in
> that format.
> So if color is white I need to get "#FFFFFF"
> Thanks,
> Miguel
This function should do the trick:
public static string GetRgbHex(Color c)
{
return string.Format("{0:x6}", c.ToArgb() & 0xFFFFFF);
}
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net "shapper" <mdmo
@gmail.com> wrote in message
news:1180475569.740612.274840@h2g2000hsg.googlegroups.com...
> Hello,
> How can I convert a variable of type color to a String where the color
> is in the format #FFFFFF?
> Thanks,
> Miguel