class A
{
public Color ColorA { get; set; }
public Color ColorB { get; set; }
public A(Color colorA, Color colorB)
{
ColorA = colorA;
ColorB = colorB;
}
public override string ToString()
{
return ColorA + " " + ColorB;
}
}
This renders as:
And this:
class A
{
public Color ColorA { get; set; }
public Color ColorB { get; set; }
public A(Color colorA, Color colorB)
{
ColorA = colorA;
ColorB = colorB;
}
public override string ToString()
{
return "Red" + " " + "Black";
}
}
renders as:
Why the difference?
Edit: I know why the difference. My question is, how to achieve second result without hardcoding the text of the color.
Try this:
return ColorA.Name + " " + ColorB.Name;