✅ 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
Jimmacle4mo ago
by manipulating the string to cut out the parts you don't want, that's just how ToString works for that type
Buddy
Buddy4mo ago
Please don't name your thread "help" in the future, but be more descriptive
Jimmacle
Jimmacle4mo 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]";
Gυαɾԃιαɳ
GυαɾԃιαɳOP4mo ago
Sorry. It wont happen again Would this affect my other ToStrings?
Jimmacle
Jimmacle4mo ago
that isn't code for you to use that's the implemention of ToString for Color
Gυαɾԃιαɳ
GυαɾԃιαɳOP4mo ago
oo ok Ill use it to my advantage. Thanks for the help. Adios!

Did you find this page helpful?