Question: I need to serialize a color used in a WPF application to a database. I'd like to use the sRGB values, because they're more familiar to those of us that have spent the last few years doing web development.

How can a get an ARGB string (like #FFFFFFFF) from a System.Windows.Media.Color object?

**UPDATE**: I was misled by the documentation on MSDN. As @Kris noted below, the documentation for the `ToString()` method is incorrect. Although it says that ToString() "creates a string representation of the color using the ScRGB channels", it will actually return a string in ARGB hex format if the color was created using the `FromARGB()` method. It's an undocumented feature, I suppose. 

See <http://msdn.microsoft.com/en-us/library/ms606572.aspx>

Answer: 
There is inbuild implementation for System.Windows.Media.Color toString() method which gives hexcode of the color.

Snippet from the class interface it self

```
        //
        // Summary:
        //     Creates a string representation of the color using the sRGB channels.
        //
        // Returns:
        //     The string representation of the color. The default implementation represents
        //     the System.Byte values in hex form, prefixes with the # character, and starts
        //     with the alpha channel. For example, the System.Windows.Media.Color.ToString()
        //     value for System.Windows.Media.Colors.AliceBlue is #FFF0F8FF.
        public override string ToString();

```
You can get the A, R, G and B values from a Color instance as bytes, so you just need to convert the bytes to hex and concatenate the hex values as strings.

[byte[] to hex string](https://stackoverflow.com/questions/623104/c-byte-to-hex-string)