Convert string to Color in C#

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");
This entry was posted in C# and tagged . Bookmark the permalink.

Comments are closed.