Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store Colors in string?

I want to store Color in string if they are Human Readable format and ToArgb() if they are not.

Color is Red then store it in "Red" string and If color is say some variant of green then it is store as "ff40ff80".

At runtime I want to convert this strings back to Color class Object?

like image 631
Abhijit Shelar Avatar asked Jan 12 '12 09:01

Abhijit Shelar


People also ask

How do you turn colors into string flutters?

Color color = new Color(0x12345678); String colorString = color. toString(); // Color(0x12345678) String valueString = colorString. split('(0x')[1].

What is a color string?

A colour string is a group of premixed piles of paints with different tonal values. You usually start with the darkest colour in the string (say a pure ultramarine blue) and slowly add progressively lighter 'steps' to the mixture.

How do you color a string in C#?

Solution 1. String backcolor="Red"; cat. BackColor = ColorTranslator. FromHtml(backcolor);


1 Answers

Color color = Color.Red;
string colorName = color.Name; // this gives you the ability to switch back to Color through Color.FromName()
Color sameColor = Color.FromName(colorName);
like image 144
Ophir Bushinsky Avatar answered Sep 24 '22 08:09

Ophir Bushinsky