We want to dynamically go from a list of Colors (ie, Red, Yellow, White) to the Brush object types shown in my previous article: Adding Text to Images with C# .Net Bitmap objects – We’ll show a few solutions for mapping strings to Brush Color objects.
Try this one first. Simply map your string to a Color using the FromName function like this:
Alternatively, you can use a ColorConverter like this:
Lastly, you can use Reflection on Color or Brush like this: