Convert color to hex using C#

So you want convert a .NET color to hex or a hex color to .NET color. Well, its very easy to do this. We won’t have to write lots of code or a special class for it. Thanks to ColorTranslator class. We can convert between these with only 1 line of code. Here’s how its done:

To convert a Hex color to .NET color use this code:

For converting a .NET color to Hex color, use thise code:

That was simple & easy. If you have any questions don’t hesitate to leave a comment.


Read More