✅ Help 2.0

Color accentColor = Properties.Settings.Default.accentColor;
string color = accentColor.ToString();
Color accentColor = Properties.Settings.Default.accentColor;
string color = accentColor.ToString();
This returns "Color [Red]" How do I make it return "Red"?
6 Replies
Jimmacle
Jimmacle10mo ago
by manipulating the string to cut out the parts you don't want, that's just how ToString works for that type
Buddy
Buddy10mo ago
Please don't name your thread "help" in the future, but be more descriptive
Jimmacle
Jimmacle10mo ago
public override string ToString() =>
IsNamedColor ? $"{nameof(Color)} [{Name}]" :
(state & StateValueMask) != 0 ? $"{nameof(Color)} [A={A}, R={R}, G={G}, B={B}]" :
$"{nameof(Color)} [Empty]";
public override string ToString() =>
IsNamedColor ? $"{nameof(Color)} [{Name}]" :
(state & StateValueMask) != 0 ? $"{nameof(Color)} [A={A}, R={R}, G={G}, B={B}]" :
$"{nameof(Color)} [Empty]";
𝓦𝓲𝓵𝓭𝓒𝓪𝓻𝓭
Sorry. It wont happen again Would this affect my other ToStrings?
Jimmacle
Jimmacle10mo ago
that isn't code for you to use that's the implemention of ToString for Color
𝓦𝓲𝓵𝓭𝓒𝓪𝓻𝓭
oo ok Ill use it to my advantage. Thanks for the help. Adios!

Did you find this page helpful?