HOW TO CONVERT HTML COLOR TO RGB IN C#?

Pravesh Singh

Total Post:412

Points:2888
Posted by  Pravesh Singh
C# 
C#
 5265  View(s)
Ratings:
Rate this:

Hi,

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

  1. Arun Singh

    Post:68

    Points:476
    Re: how to convert html color to rgb in c#?

    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");

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!