Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In C# , How can i create a System.Drawing.Color object using a hex value? [duplicate]

In C# , How can i create a System.Drawing.Color object using a value like this #FFFFF,#FGFG01 etc...

like image 265
Shyju Avatar asked Nov 19 '09 10:11

Shyju


People also ask

What is '~' in C language?

In mathematics, the tilde often represents approximation, especially when used in duplicate, and is sometimes called the "equivalency sign." In regular expressions, the tilde is used as an operator in pattern matching, and in C programming, it is used as a bitwise operator representing a unary negation (i.e., "bitwise ...


1 Answers

string hexValue = "#000000"; // You do need the hash
Color colour = System.Drawing.ColorTranslator.FromHtml(hexValue); // Yippee

Edit: You do actually need the hash, or the alpha value won't be taken into account. Woops!

like image 58
djdd87 Avatar answered Oct 01 '22 20:10

djdd87