I have a bunch of Color
objects (.Net). I want to convert them to Hex, which is simple enough with something like:
Dim clr As Color = Color.FromArgb(255, 0, 0)
Dim clrString = ColorTranslator.ToHtml(clr)
Is there a way in .Net or through RegEx (or some other way) that I can determine if Hex shorthand (like #F00
) is available for the specified Color
and then convert it to that? So for colors that can have a Hex shorthand, convert to that, otherwise, convert to Hex Pair #FF0000
.