Mega Code Archive

 
Categories / C# / 2D Graphics
 

Returns an HTML #XXXXXX format for a color

using System; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Collections.Generic; public static class Utilities {     public static string ColorToHtml(Color c)     {         return "#" + c.R.ToString("X2", null) + c.G.ToString("X2", null) + c.B.ToString("X2", null);     } }