Convert string to Color in C#

后端 未结 10 1334
我寻月下人不归
我寻月下人不归 2020-11-29 07:03

I am encountering a problem which is how do I convert input strings like \"RED\" to the actual Color type Color.Red in C#. Is there a good way to do this?

10条回答
  •  萌比男神i
    2020-11-29 07:50

    System.Drawing.Color myColor = System.Drawing.ColorTranslator.FromHtml("Red");
    

    (Use my method if you want to accept HTML-style hex colors.)

提交回复
热议问题