How do I get the color from a hexadecimal color code using .NET?

c#, colors, hex, wpf

Solution

I'm assuming that's an ARGB code... Are you referring to `System.Drawing.Color` or `System.Windows.Media.Color`? The latter is used in WPF for example. I haven't seen anyone mention it yet, so just in case you were looking for it:

using System.Windows.Media;

Color color = (Color)ColorConverter.ConvertFromString("#FFDFD991");

Problem

How can I get a color from a hexadecimal color code (e.g. `#FFDFD991`)? I am reading a file and am getting a hexadecimal color code. I need to create the corresponding `System.Windows.Media.Color` instance for the hexadecimal color code. Is there an inbuilt method in the framework to do this?

Original source

Related problems