Home > DeveloperSection > Forums > how to convert html color to rgb in c#?
Pravesh Singh

Total Post:411

Posted on    July-16-2012 4:32 AM

 C# C# 

 1 Reply(s)
 4648  View(s)
Rate this:


Can anyone tell me how to convert html color to rgb in c#. Please give the code if possible.

Arun Singh

Total Post:68

Posted on    July-21-2012 1:28 AM

Hi Pravesh Singh,
You can use this code to resolve your problem....
using System.Drawing;
using System;

//convert to the HTML color value of a known System.Drawing.Color
string htmlNamedColorValue = ColorTranslator.ToHtml(Color.Crimson);

//convert to System.Drawing.Color from HTML hex color value
Color colorValueFrmHex =  ColorTranslator.FromHtml("#FFFF33");

 //convert to System.Drawing.Color from HTML known color
 Color colorValue = ColorTranslator.FromHtml("DarkRed");

Don't want to miss updates? Please click the below button!

Follow MindStick