Color From Name - CSharp System.Drawing

CSharp examples for System.Drawing:Color

Description

Color From Name

Demo Code


using System.Windows;
using System.Reflection;
using System.Windows.Media;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from   w ww  .  j  ava 2 s .  c o  m*/

public class Main{
        public static Color ColorFromName(string name)
        {
            var colortype = typeof(Colors);
            return (Color)colortype.GetProperty(name).GetValue(colortype, null);
        }
}

Related Tutorials