For example:
blue
converts to:
#0000FF
I wrote it as:
Color color = Color.FromName(\"blue\
Ahmed's answer is close, but based on your comment, I'll just add a little more.
The code that should make this work is:
Color color = Color.FromName("blue");
string myHexString = String.Format("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B);
Now you can do whatever you want with the string myHexString.