views:

1985

answers:

3

What is the best way to turn strings like "red", "green", "yellow", "aliceblue", etc... into the actual System.Drawing.Color value?

I was looking at reflection and something about that didn't seem right.

+6  A: 

System.Drawing.Color.FromName("Red");

DavidN
System.Drawing.Color is a struct, no enum.
Alex Reitbort
Was thinking one thing, typing another ;)
DavidN
+7  A: 

public static Color FromName(string name)

Color c = Color.FromName("AliceBlue")

Moose
+11  A: 

You can use Color.FromName()

Alex Reitbort