Method TryParse
TryParse(string, out Color)
Tries to parse a Color from a string.
public static bool TryParse(string colorString, out Color color)
Parameters
colorStringstringThe string to parse.
colorColorThe color if the parsing was successful, Black otherwise.
Returns
- bool
Whether the parsing was successful.
Remarks
The following formats are supported:
- Hexadecimal color codes, such as
"#FF0000"or"ff0000ff". - Color names from the list below, such as
"Red"or"red". - Color names from the list below, with alpha, such as
"Red 255","Red 1.0", or"Red 100%". - Gray color codes, such as
"128","0.5", or"50%". - Gray color codes with alpha, such as
"128 255","0.5, 1.0", or"50% 100%". - RGB color codes, such as
"255 0 0","1.0 0.0 0.0", or"100% 0% 0%". - RGBA color codes, such as
"255 0 0 255","1.0 0.0 0.0 1.0", or"100% 0% 0% 100%".
| Color | Color | Color |
|---|---|---|
| White | Black | Red |
| Green | Blue | Yellow |
| Cyan | Magenta | Gray |
| Grey | Clear | Orange |
| Purple | Brown | Pink |
| Lime | Navy | Olive |