To convert a Color to Hex and vice versa using C# and VB.NET you can use the snippets below.
Sample C#
private static String ColorToHex(Color inputColor)
{
return ColorTranslator.ToHtml(inputColor);
}
private static Color HexToColor(string hexInput)
{
return ColorTranslator.FromHtml(hexInput);
}
Sample VB.NET (autoconverted)
Private Shared Function ColorToHex(inputColor As Color) As [String] Return ColorTranslator.ToHtml(inputColor) End Function Private Shared Function HexToColor(hexInput As String) As Color Return ColorTranslator.FromHtml(hexInput) End Function