Digital Colony!

Convert string to Color

You will get the following error when trying to assigning a string as a Color in .NET.
Cannot implicitly convert type 'string' to 'System.Drawing.Color'

Import System.Drawing and use Color.FromName to convert a string to a color.
using System.Drawing;
Color.FromName("Blue");

Labels:

AddThis Social Bookmark Button

4 Comments:

Blogger Kull PagoN said...

Thanks too much...

8/06/2007 10:20 AM

Anonymous Anonymous said...

perfect, thanks

11/12/2007 10:54 AM

Anonymous Anonymous said...

Thank you. Very helpful.

7/23/2008 7:36 AM

Anonymous fobs said...

Thank you. Thank you!

11/02/2008 6:10 PM

 

Post a Comment

 

Digital Colony Copyright © 1999-2008 XHTML   508
This site uses Blogger, which is not 100% XHTML compliant.
Try...Catch Disclaimer: For brevity many examples do not include error handling. That is your responsibility.