CSharp examples for System.Drawing:Color Convert
Convert a Color to a hexadecimal string.
using System.Windows.Media; using System.Globalization; using System;/*from w w w. jav a2s.c o m*/ public class Main{ /// <summary> /// Convert a <see cref="Color"/> to a hexadecimal string. /// </summary> /// <param name="color"> /// </param> /// <returns> /// The color to hex. /// </returns> public static string ColorToHex(Color color) { return string.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", color.A, color.R, color.G, color.B); } }