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:

posted by MAS on Feb 15,2007

Digital Colony Copyright © 1999-2010 XHTML   508
Try...Catch Disclaimer: For brevity many examples do not include error handling. That is your responsibility.